Commit ab69b755 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(main): Use pidfile to simplify code.

parent 3a9ebaa7
/* /*
* $Id: updateLysKOM.c,v 1.8 1998/12/26 22:41:11 byers Exp $ * $Id: updateLysKOM.c,v 1.9 1999/04/17 00:16:46 ceder Exp $
* Copyright (C) 1994, 1995 Lysator Academic Computer Association. * Copyright (C) 1994, 1995 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <unistd.h> #include <unistd.h>
#include "ldifftime.h" #include "ldifftime.h"
#include "pidfile.h"
static void static void
checkstatus(FILE *fp, checkstatus(FILE *fp,
...@@ -158,7 +159,7 @@ main (int argc, ...@@ -158,7 +159,7 @@ main (int argc,
{ {
case 'V': case 'V':
case 'v': case 'v':
fprintf(stderr, "updateLysKOM %d $Revision: 1.8 $\n", fprintf(stderr, "updateLysKOM %d $Revision: 1.9 $\n",
#include "version.incl" #include "version.incl"
); );
exit(0); exit(0);
...@@ -167,23 +168,11 @@ main (int argc, ...@@ -167,23 +168,11 @@ main (int argc,
fprintf(stderr, "usage: %s [-V]\n", argv[0]); fprintf(stderr, "usage: %s [-V]\n", argv[0]);
} }
fp = fopen(DEFAULT_PREFIX "/etc/pid", "r"); pid = read_pid_file(DEFAULT_PREFIX "/etc/pid", argv[0]);
if (fp == NULL) if (pid == 1)
{ {
fprintf(stderr, "%s: warning: %s: ", argv[0], fprintf(stderr, "%s: got pid %ld.\n", argv[0], pid);
DEFAULT_PREFIX "/etc/pid"); exit(1);
perror("");
pid = 0;
}
else
{
pid = 0;
fscanf(fp, "%lu", &pid);
if (pid < 2)
{
fprintf(stderr, "%s: got pid %ld.\n", argv[0], pid);
exit(1);
}
} }
fp = fopen(DEFAULT_PREFIX "/etc/status", "r"); fp = fopen(DEFAULT_PREFIX "/etc/status", "r");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment