diff options
author | bde <bde@FreeBSD.org> | 1998-06-28 20:40:51 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 1998-06-28 20:40:51 +0000 |
commit | 4e8e4d585c351ad28b0572b154c3fa1683dccbba (patch) | |
tree | 8e84da496b2900631aea8cd799668c2bbb31405d | |
parent | 21b894709fabc405f5c1204667b0f3aecbc970d2 (diff) | |
download | FreeBSD-src-4e8e4d585c351ad28b0572b154c3fa1683dccbba.zip FreeBSD-src-4e8e4d585c351ad28b0572b154c3fa1683dccbba.tar.gz |
Fixed printf format errors, scanf format errors and scanf error handling.
-rw-r--r-- | sbin/startslip/startslip.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sbin/startslip/startslip.c b/sbin/startslip/startslip.c index d2e252a..b639c00 100644 --- a/sbin/startslip/startslip.c +++ b/sbin/startslip/startslip.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: startslip.c,v 1.26 1997/12/21 15:35:22 eivind Exp $ + * $Id: startslip.c,v 1.27 1997/12/22 13:46:08 eivind Exp $ */ #ifndef lint @@ -126,6 +126,7 @@ main(argc, argv) char *upscript = NULL, *downscript = NULL; int first = 1, tries = 0; time_t fintimeout; + long lpid; pid_t pid; struct termios t; @@ -216,10 +217,11 @@ main(argc, argv) dvname++; sprintf(pidfile, PIDFILE, _PATH_VARRUN, dvname); if ((pfd = fopen(pidfile, "r")) != NULL) { - pid = 0; - fscanf(pfd, "%ld\n", &pid); - if (pid > 0) - kill(pid, SIGTERM); + if (fscanf(pfd, "%ld\n", &lpid) == 1) { + pid = lpid; + if (pid == lpid && pid > 0) + kill(pid, SIGTERM); + } fclose(pfd); pfd = NULL; /* not remove pidfile yet */ sleep(5); /* allow down script to be completed */ @@ -280,9 +282,9 @@ restart: } pid = getpid(); - printd("restart: pid %ld: ", pid); + printd("restart: pid %ld: ", (long)pid); if ((pfd = fopen(pidfile, "w")) != NULL) { - fprintf(pfd, "%ld\n", pid); + fprintf(pfd, "%ld\n", (long)pid); fclose(pfd); } printd("open"); |