This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Checking if pipe is still open

Old posts that have not been replied to for several years.
Locked
M
Massacre
Voice
Posts: 27
Joined: Wed Mar 19, 2003 4:17 pm

Checking if pipe is still open

Post by Massacre »

Is there a way I can check whether the pipe to my java prog is still open?
M
Massacre
Voice
Posts: 27
Joined: Wed Mar 19, 2003 4:17 pm

Post by Massacre »

Ok, i've fixed this now by doing the following check:

Code: Select all

 [catch [pid $pipe]] != "0"
If it's != "0" then there was an err (eg, $pipe doesn't exist anymore) and I can restart the java prog.
M
Massacre
Voice
Posts: 27
Joined: Wed Mar 19, 2003 4:17 pm

Post by Massacre »

hmmz, ok no i didn't, the problem still stands, cause catch is always returning 1.
M
Massacre
Voice
Posts: 27
Joined: Wed Mar 19, 2003 4:17 pm

Post by Massacre »

Ha, ok, so it should be "pid $pipe" not [pid $pipe] and it works now but it still returns the PID even if the stream is closed, so does anyone know a working method please?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

what do u mean if a dcc is open or what ever maybe use

if {[info exists varname]}

stuff like that valididx ..? what is the open pipe ??

if its a file then use eof or something ..
XplaiN but think of me as stupid
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Checking if pipe is still open

Post by user »

Massacre wrote:Is there a way I can check whether the pipe to my java prog is still open?
It will be "open" untill you 'close' it. I think what you want is 'eof' :)
Have you ever read "The Manual"?
M
Massacre
Voice
Posts: 27
Joined: Wed Mar 19, 2003 4:17 pm

Post by Massacre »

I'm trying to test for the java prog exiting unexpetidly cause what happens is, the java prog dies then @ the next call to gets it's probably reading -1 or something and it hangs, cpu hits 100% and has to be killed. Is the only way round this to build my own gets proc and reload the java prog when im gettin -1 or whatever (EOF didn't work cause pipe was alive @ last call to gets).
M
Massacre
Voice
Posts: 27
Joined: Wed Mar 19, 2003 4:17 pm

Post by Massacre »

Even on non-blocking mode it still hangs and uses 100% cpu when the java prog is dead :(
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Then you have an *infinite* loop that is not been closed. :mrgreen:
Once the game is over, the king and the pawn go back in the same box.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

So the java program exits, it doesn't hang? Then what is using 100% cpu, eggdrop? That means you're doing something wrong, such as...

1. you have a loop with gets, but are using nonblocking mode
2. you have a loop with gets, in blocking mode, but aren't checking for eof
3. you have fconfigured events with nonblocking mode, but never close the pipe

That's to start with anyway. It's really impossible to say without you posting at least some of your code. Also, try adding debugging info (to eggdrop, and your java program).
Locked