summaryrefslogtreecommitdiffstats
path: root/pidfile.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2006-02-16 13:57:35 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2006-02-16 13:57:35 +0000
commit0faf9d9dbaa92266dcaa62d552b12cc922b55d9d (patch)
tree8222728e86c02d0d128aaac50963a7005ec17a8c /pidfile.c
parent324afbb734d9e36ce474f2b549f50b8a10fb2264 (diff)
downloadrsyslog-0faf9d9dbaa92266dcaa62d552b12cc922b55d9d.tar.gz
rsyslog-0faf9d9dbaa92266dcaa62d552b12cc922b55d9d.tar.xz
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.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/pidfile.c b/pidfile.c
index 08520293..754ac532 100644
--- a/pidfile.c
+++ b/pidfile.c
@@ -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;