Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Dec 2001 20:31:44 +0100
From:      Gabriel Ambuehl <gabriel_ambuehl@buz.ch>
To:        questions@freebsd.org
Subject:   Question about shutdown of TCP daemons...
Message-ID:  <84888543528.20011214203144@buz.ch>

next in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----

Hello,
I've there got an app which consists of two daemons,
d1 and d2, both are the same binary just running two different
compartments (they get created by two successive fork()s from inital
process) now d2 got a SOAP RPC (Easysoap++) installed in order to
respond to queries over SOAP and listens on port 6060. The queries
come from two sides:
1) from children of d1, which report some processing results to d2 to
be stored
2) from clients of d2, which want to obtain the data of d1


So far, everything is working charmingly but now I need to add a SOAP
RPC call
that will reload the config of both daemons from the initial config
file.

I came up with something like:

d2:
[...]
  kill(d1_pid, SIGHUP);
  return_soap_query(); //the client wants to see something, else it
                     //won't be happy at all so we can't just exit(0)
  return 1;
}


which lets d1 execute:
void sighup(int signo)
  {
    kill(d2_pid, SIGKILL); //d2 exits, which should allow other
people
                           //to bind to port 6060
    if(fork()==0)
      { /*child*/
        cout << getpid() << endl;
        setsid();
        for (int i=0; i==1024; i++)
          {
            close(i);
          }
        execv(original_argv[0], original_argv);
      }
    _exit(0);
  }


Now while both exit and a new instance is loaded by the execv, the
new
d2 isn't able to bind to port 6060 since it is still occupied by
something (which is also what nmap says) and it will only become free
after d2 exited stating it isn't able to bind to port.

What am I doing wrong?



TIA & best regards,
 Gabriel

PS:
On the cli,
#killall app && ./app config.file

will do just fine, whereas in the app,

system("killall app && ./app config.file");

won't do any good except killing all instances of app.

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5i

iQEVAwUBPBpFlcZa2WpymlDxAQFz2AgAnZvBWyS26Fv54c11YpuIPzdVGEqsguWd
AVCAXvORnCC/j4SPuH2qjNiApiGQXQwCljjCUVp7ZuSjGLyErY6GGMTsVEsM+NbK
WptariCO/2pxlZySXhNt04dGZ/sczYzpeBLIU9znAHgYH3QmM6Sn+Y6xS4BXh9CJ
VUvIjArSFkmbuAA+eClKZ6fVdEyUrmMBcjnMqHcybIzbfJNTiQTvDMakHvdbufg+
zGUDgfMCoyWerB2MSA8n7z9cnhDjrBnPYW+jFoFyZAm+Pz1MWdjzrap14lmLp4VG
2r73g7uLC8UhH2h57N0QkUyEh745zduSssB5ZQboxVcWUZ3699WO1Q==
=T4ga
-----END PGP SIGNATURE-----


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?84888543528.20011214203144>