--- ./sysklogd/syslogd.c.flx4-nopid 2006-03-30 22:32:43.000000000 +0200 +++ ./sysklogd/syslogd.c 2006-03-30 22:49:32.000000000 +0200 @@ -60,6 +60,8 @@ static const char *logFilePath = __LOG_FILE; +static const char *pidFilePath = NULL; + #ifdef CONFIG_FEATURE_ROTATE_LOGFILE /* max size of message file before being rotated */ static int logFileSize = 200 * 1024; @@ -507,6 +509,8 @@ { logMessage(LOG_SYSLOG | LOG_INFO, "System log daemon exiting."); unlink(lfile); + if (pidFilePath) + unlink(pidFilePath); #ifdef CONFIG_FEATURE_IPC_SYSLOG ipcsyslog_cleanup(); #endif @@ -795,7 +799,7 @@ char *p; /* do normal option parsing */ - while ((opt = getopt(argc, argv, "m:nO:s:uSb:R:Ll:k:K:C::")) > 0) { + while ((opt = getopt(argc, argv, "m:nO:p:s:uSb:R:Ll:k:K:C::")) > 0) { switch (opt) { case 'm': MarkInterval = atoi(optarg) * 60; @@ -806,6 +810,9 @@ case 'O': logFilePath = optarg; break; + case 'p': + pidFilePath = optarg; + break; #ifdef CONFIG_FEATURE_ROTATE_LOGFILE case 's': logFileSize = atoi(optarg) * 1024; @@ -885,8 +892,6 @@ *p = '\0'; } - umask(0); - if (doFork == TRUE) { #if defined(__uClinux__) vfork_daemon_rexec(0, 1, argc, argv, "-n"); @@ -896,7 +901,18 @@ #endif /* __uClinux__ */ close(0); close(1); close(2); open("/dev/null", O_RDWR); dup(0); dup(0); + if (pidFilePath != NULL) { + FILE *f; + + f = fopen(pidFilePath, "w+"); + if (f != NULL) { + fprintf(f, "%d\n", getpid()); + fclose(f); + } + } } + umask(0); + doSyslogd(); return EXIT_SUCCESS; --- ./include/usage.h.orig 2006-03-30 23:08:03.000000000 +0200 +++ ./include/usage.h 2006-03-30 23:09:03.000000000 +0200 @@ -2909,6 +2909,7 @@ "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" \ "\t-S\t\tMake logging output smaller." \ "\n\t-u\t\tDo not bind to UNIX socket /dev/log." \ + "\n\t-p PIDFILE\tWrite background process ID to this file." \ USAGE_ROTATE_LOGFILE( \ "\n\t-s SIZE\t\tMax size (KB) before rotate (default=200KB, 0=off)\n" \ "\t-b NUM\t\tNumber of rotated logs to keep (default=1, max=99, 0=purge)") \