Unix Programming - forking a shell process [ksh -c "command&"] - session leader

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > July 2006 > forking a shell process [ksh -c "command&"] - session leader





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author forking a shell process [ksh -c "command&"] - session leader
pankajtakawale

2006-07-17, 1:20 pm

I have a server-program which forks a process to execute - ksh -c
"command&"
server forks a process to execute ksh
ksh forks child process to execute 'command'
But this child process receives SIGHUP before exec'ing command
and 'command' doesnt get executed at all.

This is probably happening because ksh is a session leader, and as ksh
dies after forking child process, system sends SIGHUP to all of its
session members.
**ksh -c "nohup command&" also doesnt work as child process recives
SIGHUP before exec;ing.**

I have written a simple daemon program [umask, setsid, no controlling
ttys] which forks a child process and execute the command.
And changed server-program to execute this daemon like - daemon ksh -c
"command&".
In above case , session leader is daemon, & not a ksh. Its working fine
for now.

I guess 'command' is not reciving SIGHUP because:- this daemon is not
associated with controlling terminals, so tty driver wont send SIGHUP
to any members on the death of session leader daemon.
Is it what happening over here? any other elegant solution?

I tried making servers' child process (which is going to fork to
execute ksh) daemon, but this doesnt work all the time. I observed that
when I 'strace' server-program , it works fine. Else it doesnt start
'command' at background.
why so?
What would be the elegant solution here.

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com