diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2006-02-16 13:57:35 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2006-02-16 13:57:35 +0000 |
commit | 0faf9d9dbaa92266dcaa62d552b12cc922b55d9d (patch) | |
tree | 8222728e86c02d0d128aaac50963a7005ec17a8c /pidfile.c | |
parent | 324afbb734d9e36ce474f2b549f50b8a10fb2264 (diff) | |
download | rsyslog-0faf9d9dbaa92266dcaa62d552b12cc922b55d9d.tar.gz rsyslog-0faf9d9dbaa92266dcaa62d552b12cc922b55d9d.tar.bz2 rsyslog-0faf9d9dbaa92266dcaa62d552b12cc922b55d9d.zip |
now it compiles under solaris, but I could not yet test it (need to find
out how to disable stock syslogd on this platform ;))
Diffstat (limited to 'pidfile.c')
-rw-r--r-- | pidfile.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -31,6 +31,9 @@ #include <string.h> #include <errno.h> #include <signal.h> +#ifdef __sun +#include <fcntl.h> +#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; |