string s_pidfname;
static void writePid(void)
{
- s_pidfname=::arg()["socket-dir"]+"/"+s_programname+".pid";
- ofstream of(s_pidfname.c_str());
+ ofstream of(s_pidfname.c_str(), ios_base::app);
if(of)
of<< Utility::getpid() <<endl;
else
#ifndef WIN32
void daemonize(void)
{
- s_rcc.d_dontclose=true;
if(fork())
exit(0); // bye bye
makeUDPServerSockets();
makeTCPServerSockets();
+
+ s_pidfname=::arg()["socket-dir"]+"/"+s_programname+".pid";
+ if(!s_pidfname.empty())
+ unlink(s_pidfname.c_str()); // remove possible old pid file
#ifndef WIN32
if(::arg().mustDo("fork")) {
#endif
MT=new MTasker<PacketID,string>(::arg().asNum("stack-size"));
- makeControlChannelSocket();
PacketID pident;
primeHints();
L<<Logger::Warning<<"Done priming cache with root hints"<<endl;
signal(SIGPIPE,SIG_IGN);
writePid();
#endif
+ makeControlChannelSocket();
g_fdm=getMultiplexer();
for(deferredAdd_t::const_iterator i=deferredAdd.begin(); i!=deferredAdd.end(); ++i)
RecursorControlChannel::RecursorControlChannel()
{
d_fd=-1;
- d_dontclose=false;
*d_local.sun_path=0;
}
{
if(d_fd > 0)
close(d_fd);
- if(*d_local.sun_path && !d_dontclose)
+ if(*d_local.sun_path)
unlink(d_local.sun_path);
}