aboutsummaryrefslogtreecommitdiff
path: root/sbin/startslip/startslip.c
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1998-06-28 20:40:51 +0000
committerBruce Evans <bde@FreeBSD.org>1998-06-28 20:40:51 +0000
commit00e0c280db5942915c7d22e039f451bee80e5a41 (patch)
treea9df2ec1c0ada4cf0429f276b1b584a6e03ff7ec /sbin/startslip/startslip.c
parent836b4a7ff9a36d909cc21970c90eb03ef3c5944c (diff)
downloadsrc-00e0c280db5942915c7d22e039f451bee80e5a41.tar.gz
src-00e0c280db5942915c7d22e039f451bee80e5a41.zip
Fixed printf format errors, scanf format errors and scanf error handling.
Notes
Notes: svn path=/head/; revision=37242
Diffstat (limited to 'sbin/startslip/startslip.c')
-rw-r--r--sbin/startslip/startslip.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sbin/startslip/startslip.c b/sbin/startslip/startslip.c
index d2e252ab7987..b639c00c6f46 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");