Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

5 x Re: how to make a demon in perl?

by blm (Hermit)
on Oct 01, 2002 at 13:59 UTC ( [id://202006]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: how to make a demon in perl?
in thread how to make a demon in perl?

I can see what is happening I am just having trouble understanding why it works

I figured the order was important. I thought if the child inherited normal STDIN etc then redirected them it would be the same as running a normal script and trying to detach by redirecting STDIN etc (see 1). The child wouldn't be detached and would die on SIGHUP or whatever.

I might just have to accept that I see it but don't fully understand it. Thanks for your posts though!


(1) I have tried the daemon script without fork and it doesn't work since just doing the redirecting of file descriptors of a process doesn't seem to detach.

--blm--

Replies are listed 'Best First'.
Re: 5 x Re: how to make a demon in perl?
by zigdon (Deacon) on Oct 01, 2002 at 14:15 UTC
    Ok - I think I see your confusion. As far as I know, there is no connection between file descriptiors and signals. Meaning, the fact that you close redirect your STDIN/STDERR in your script doesn't stop the shell from sending you a SIGHUP when the parent exits. You have to disassociate yourself from your parent process, which is what the setsid call does (I think).

    -- Dan

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://202006]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-25 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found