X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=miscutil.c;h=ed09ff8d0f53ca14740696f4d6478a907f462049;hb=033aba083fddaa1c758028e955c16cf7d5c94834;hp=bea387eee1f8ffa3db56a1dbb819ff7e5444763f;hpb=605576ce35e16c57567f79dd9086bb9ae001753b;p=privoxy.git diff --git a/miscutil.c b/miscutil.c index bea387ee..ed09ff8d 100644 --- a/miscutil.c +++ b/miscutil.c @@ -1,4 +1,4 @@ -const char miscutil_rcs[] = "$Id: miscutil.c,v 1.24 2001/11/05 21:41:43 steudten Exp $"; +const char miscutil_rcs[] = "$Id: miscutil.c,v 1.25 2001/11/13 00:16:38 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $ @@ -36,6 +36,10 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.24 2001/11/05 21:41:43 steudten * * Revisions : * $Log: miscutil.c,v $ + * Revision 1.25 2001/11/13 00:16:38 jongfoster + * Replacing references to malloc.h with the standard stdlib.h + * (See ANSI or K&R 2nd Ed) + * * Revision 1.24 2001/11/05 21:41:43 steudten * Add changes to be a real daemon just for unix os. * (change cwd to /, detach from controlling tty, set @@ -158,7 +162,11 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.24 2001/11/05 21:41:43 steudten #include "config.h" #include +#include #include +#if !defined(_WIN32) && !defined(__OS2__) +#include +#endif /* #if !defined(_WIN32) && !defined(__OS2__) */ #include #include #include @@ -193,7 +201,52 @@ void *zalloc(int size) return(ret); } +#if defined(unix) +/********************************************************************* + * + * Function : deletePidFile + * + * Description : deletes the pid file with the pid of the main process + * + * Parameters : - + * + * Returns : - + * + *********************************************************************/ +void deletePidFile( void ) +{ + char pidfile[ 64 ]; + snprintf( pidfile, sizeof(pidfile), "%s/%s", PID_FILE_PATH, PID_FILE_NAME); + unlink( pidfile ); +} +/********************************************************************* + * + * Function : writePidFile + * + * Description : writes the pid file with the pid of the main process + * + * Parameters : - + * + * Returns : - + * + *********************************************************************/ +void writePidFile( void ) +{ + FILE *fp; + char pidfile[64]; + + snprintf( pidfile, sizeof(pidfile), "%s/%s", PID_FILE_PATH, PID_FILE_NAME); + if ((fp = fopen( pidfile,"w")) == NULL ) + { + log_error(LOG_LEVEL_INFO, "can't open pidfile '%s': %E", pidfile); + return; + } + + fprintf( fp,"%u\n", (unsigned int) getpid()); + fclose ( fp ); +} +#endif /* unix */ /********************************************************************* *