Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Named Pipe(interrupt?)

Status
Not open for further replies.

SiouxCityElvis

Programmer
Jun 6, 2003
228
US
I'm having a problem with my named pipe read.
The snippet below is my COBOL that reads two files, my command-file which checks for shutting down this app, and the named pipe file, which checks for requests to process.
I've got it tested and verified that the named pipe works and will take several requests as they are fed through the named pipe. My problem is: I run this application and test it with two different requests being written to the Named pipe file. It processes those properly. Then I run another application that writes "SHUTDOWN" to the COMMAND-FILE. But, it doesn't catch that and shutdown this application. I have verified through debugging that the cause is due to it having already processed the 2 requests, looped again past the COMMAND-FILE part and arrived again at the OPEN INPUT PIPE-FILE part before the SHUTDOWN value was written to the COMMAND-FILE. I have also verified that it is sitting at the OPEN INPUT PIPE-FILE waiting for it to be filled again with another request before moving on down the rest of the code. Apparently, that is how a named pipe works. My problem is that it should shutdown since SHUTDOWN is now in the COMMAND-FILE, but it can't because it won't go back up to the top of the loop since it's hanging on the OPEN INPUT PIPE-FILE statement. Any suggestions on how to fix this or usage of a name pipe feature that may give me a work around on this problem?

Thanks in advance.
-David

FILE SECTION.
FD COMMAND-FILE.
01 COMMAND-LINE PIC X(8).
88 IS-SHUTDOWN VALUE "SHUTDOWN".

WORKING-STORAGE.

TEST-INPUT-PIPE.

OPEN INPUT COMMAND-FILE
READ COMMAND-FILE
NOT AT END
IF IS-SHUTDOWN
GO TO END-IT(closes all files, etc)
ELSE
DISPLAY "NOT SHUTDOWN"
END-IF
END-READ
CLOSE COMMAND-FILE.

OPEN INPUT PIPE-FILE.
READ PIPE-FILE
AT END
DISPLAY "AT END OF PIPE?" LINE 1 POSITION 1
NOT AT END
...do processing...
...
END-READ.
CLOSE PIPE-FILE.
GO TO TEST-INPUT-PIPE.
 
Don't know cobol at all, but can you put some sort of sleep just after the shutdown giving time for the value to be written to the file.
 
Eventually maybe.

For now, we'll probably just send in a request written to the named pipe with "SHUTDOWN" as the value. I'll implement IF THEN code in my PIPE-FILE part of code to handle that situation and Shut down the app accordingly.

Thanks.
-David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top