Porting to SunOS 5.8:
- Include all header files necessary - Check for flock() function
This commit is contained in:
parent
7d0f82bd4b
commit
56bd0864e4
2 changed files with 9 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
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)
|
AC_INIT(src/tincd.c)
|
||||||
AM_INIT_AUTOMAKE(tinc, 1.0pre3)
|
AM_INIT_AUTOMAKE(tinc, 1.0pre3)
|
||||||
|
|
@ -46,7 +46,7 @@ dnl Checks for library functions.
|
||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
AC_TYPE_SIGNAL
|
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_MALLOC
|
||||||
jm_FUNC_REALLOC
|
jm_FUNC_REALLOC
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
/* read_pid
|
/* read_pid
|
||||||
*
|
*
|
||||||
|
|
@ -94,12 +96,14 @@ int write_pid (char *pidfile)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_FLOCK
|
||||||
if (flock(fd, LOCK_EX|LOCK_NB) == -1) {
|
if (flock(fd, LOCK_EX|LOCK_NB) == -1) {
|
||||||
fscanf(f, "%d", &pid);
|
fscanf(f, "%d", &pid);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
printf("Can't lock, lock is held by pid %d.\n", pid);
|
printf("Can't lock, lock is held by pid %d.\n", pid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
if (!fprintf(f,"%d\n", pid)) {
|
if (!fprintf(f,"%d\n", pid)) {
|
||||||
|
|
@ -109,11 +113,13 @@ int write_pid (char *pidfile)
|
||||||
}
|
}
|
||||||
fflush(f);
|
fflush(f);
|
||||||
|
|
||||||
|
#ifdef HAVE_FLOCK
|
||||||
if (flock(fd, LOCK_UN) == -1) {
|
if (flock(fd, LOCK_UN) == -1) {
|
||||||
printf("Can't unlock pidfile %s, %s.\n", pidfile, strerror(errno));
|
printf("Can't unlock pidfile %s, %s.\n", pidfile, strerror(errno));
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue