* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
-static char rcsid[] = "$Id: utils.c,v 1.1 1999/04/12 06:24:53 paulus Exp $";
+static char rcsid[] = "$Id: utils.c,v 1.4 1999/05/12 06:15:33 paulus Exp $";
#endif
#include <stdio.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#ifdef SVR4
+#include <sys/sysmacros.h>
+#endif
#include "pppd.h"
+#if defined(SUNOS4)
+extern char *strerror();
+#endif
+
static void pr_log __P((void *, char *, ...));
static void logit __P((int, char *, va_list));
static void vslp_printer __P((void *, char *, ...));
* lock - create a lock file for the named device
*/
int
-lock(char *dev)
+lock(dev)
+ char *dev;
{
#ifdef LOCKLIB
int result;
lock_buffer[n] = 0;
pid = atoi(lock_buffer);
#endif /* LOCK_BINARY */
- if (pid == 0 || pid == getpid()
+ if (pid == getpid())
+ return 1; /* somebody else locked it for us */
+ if (pid == 0
|| (kill(pid, 0) == -1 && errno == ESRCH)) {
if (unlink (lock_file) == 0) {
notice("Removed stale lock on %s (pid %d)", dev, pid);
* between when the parent died and the child rewrote the lockfile).
*/
int
-relock(int pid)
+relock(pid)
+ int pid;
{
#ifdef LOCKLIB
/* XXX is there a way to do this? */