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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNIX daemon goes down after closing perl 1

Status
Not open for further replies.

gilshalev

Programmer
Jan 8, 2008
6
IL
Hi
We run Perl from windows, creating a Telnet object, using a UNIX command to raise a daemon.
Once we close the Perl session, and check the UNIX manually, the daemon is down.
Why doesn't it stay up?
What can we do?

Thanks,
Gil
 
This sounds more like a unix problem than a perl problem. If you use another telnet client and issue the same command, do you get the same problem?

There are many reasons why the daemon might exit but the most likely one is that it detects the end of the telnet session. The kernel will normally send it a SIGHUP to inform it that it's controlling terminal (the pseudo-tty associated with the telnet session) has closed. You can guard against this by prefixing the unix command with [tt]nohup[/tt], which blocks the signal.

HTH,

fish


["]As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life was going to be spent in finding mistakes in my own programs.["]
--Maurice Wilkes, 1949
 
Are you using the telnet to just start the daemon and leave? if so put a "&" (no quote's) after the command you are running in your telnet session that will create a detached process.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
I'm not sure that just putting & in front of the command will do the trick, as although the shell will run it in the background I think it will still get killed when you sign off. fishiface's nohup solution ought to work though...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
putting a "&" at the end of the command forks it off into it's own process. It is no longer attached to the current terminal process and doesn't die if the terminal is exited. The difference between is that nohuping a process causes it to ignore interrupts which is why it doens't die when exited.. which a person could not want if they still want to be able to send interrupts to the program. You can ignore interrupts and put it in the background (which is sometimes useful) by doing nohup process &.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top