From: Guus Sliepen Date: Tue, 7 Nov 2000 22:33:33 +0000 (+0000) Subject: Porting to SunOS 5.8: X-Git-Tag: release-1.0pre3~10 X-Git-Url: https://tinc-vpn.org/git/browse?a=commitdiff_plain;h=56bd0864e4c5680fee59af48228b1ec3fb97b57b;p=tinc Porting to SunOS 5.8: - Include all header files necessary - Check for flock() function --- diff --git a/configure.in b/configure.in index beab3517..3295de99 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -dnl $Id: configure.in,v 1.13.2.13 2000/11/02 21:38:55 zarq Exp $ +dnl $Id: configure.in,v 1.13.2.14 2000/11/07 22:33:33 guus Exp $ AC_INIT(src/tincd.c) AM_INIT_AUTOMAKE(tinc, 1.0pre3) @@ -46,7 +46,7 @@ dnl Checks for library functions. AC_FUNC_MEMCMP AC_FUNC_ALLOCA AC_TYPE_SIGNAL -AC_CHECK_FUNCS(ftime socket select strtol strerror) +AC_CHECK_FUNCS(ftime socket select strtol strerror flock) jm_FUNC_MALLOC jm_FUNC_REALLOC diff --git a/lib/pidfile.c b/lib/pidfile.c index 2f30a4e8..54a6b4c1 100644 --- a/lib/pidfile.c +++ b/lib/pidfile.c @@ -32,6 +32,8 @@ #include #include #include +#include +#include /* read_pid * @@ -93,13 +95,15 @@ int write_pid (char *pidfile) fprintf(stderr, "Can't open or create %s.\n", pidfile); return 0; } - + +#ifdef HAVE_FLOCK 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)) { @@ -109,11 +113,13 @@ int write_pid (char *pidfile) } fflush(f); +#ifdef HAVE_FLOCK 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;