From 0faf9d9dbaa92266dcaa62d552b12cc922b55d9d Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 16 Feb 2006 13:57:35 +0000 Subject: now it compiles under solaris, but I could not yet test it (need to find out how to disable stock syslogd on this platform ;)) --- pidfile.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'pidfile.c') diff --git a/pidfile.c b/pidfile.c index 08520293..754ac532 100644 --- a/pidfile.c +++ b/pidfile.c @@ -31,6 +31,9 @@ #include #include #include +#ifdef __sun +#include +#endif /* read_pid * @@ -93,12 +96,22 @@ int write_pid (char *pidfile) return 0; } + /* It seems to be acceptable that we do not lock the pid file + * if we run under Solaris. In any case, it is highly unlikely + * that two instances try to access this file. And flock is really + * causing me grief on my initial steps on Solaris. Some time later, + * we might re-enable it (or use some alternate method). + * 2006-02-16 rgerhards + */ + +#ifndef __sun if (flock(fd, LOCK_EX|LOCK_NB) == -1) { fscanf(f, "%d", &pid); fclose(f); printf("Can't lock, lock is held by pid %d.\n", pid); return 0; } +#endif pid = getpid(); if (!fprintf(f,"%d\n", pid)) { @@ -108,11 +121,13 @@ int write_pid (char *pidfile) } fflush(f); +#ifndef __sun if (flock(fd, LOCK_UN) == -1) { printf("Can't unlock pidfile %s, %s.\n", pidfile, strerror(errno)); close(fd); return 0; } +#endif close(fd); return pid; -- cgit