<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.0.9">
</HEAD>
<BODY>
you probably could do a <BR>
if program ends then<BR>
send signal stop or term<BR>
then system run program <BR>
<BR>
but i forgot if u can do another then <BR>
<BR>
<BR>
OR<BR>
<BR>
loop while program is runining = true then <BR>
do nothing <BR>
if = false then run signal term<BR>
<BR>
then just put a program exec to start the program <BR>
<BR>
loop<BR>
<BR>
<BR>
hope this info is close to correct <BR>
im not too far into my student programming career lol<BR>
<BR>
On Tue, 2003-12-02 at 22:23, Don wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE><FONT COLOR="#737373"><I>This isn't fedora-specific...

I have an application that MUST run forever.... if it crashes, dies,
ends for any reason I want it to start again.

One exception, I want to be able to stop it with a kill term...

So, my solution is a very simple loop...

for (;1==1;) {
    system(&quot;command-to-run&quot;);
    #do some sort of logging to show command-to-run ended unexpectedly
}

If my loop program gets a sig term, I want to trap that, kill the child
process and then exit gracefully.

I can trap the signal, but how do I get the pid of the child process
(command-to-run)

I tried:
for (;1==1:)
   $newpid = fork;
   if ($newpid) {
        # parent...
        wait;
        #log unexpected end of command-to-run
   } else {
        # child ...
        system(command-to-run);
        exit;
   }
}

but in that case $newpid is the pid of the child that issues &quot;system&quot;...
not the pid of &quot;command-to-run&quot;. (expected... but not what I want/need.)

Any suggestions?

Thank you,
Don




--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: </FONT><A HREF="http://www.redhat.com/mailman/listinfo/fedora-list"><U>http://www.redhat.com/mailman/listinfo/fedora-list</U></I></A></PRE>
</BLOCKQUOTE>
</BODY>
</HTML>