diff options
Diffstat (limited to 'libbb/pidfile.c')
-rw-r--r-- | libbb/pidfile.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/libbb/pidfile.c b/libbb/pidfile.c index 50af91f4e..64e67c322 100644 --- a/libbb/pidfile.c +++ b/libbb/pidfile.c | |||
@@ -17,13 +17,15 @@ int write_pidfile(const char *path) | |||
17 | char *end; | 17 | char *end; |
18 | char buf[sizeof(int)*3 + 2]; | 18 | char buf[sizeof(int)*3 + 2]; |
19 | 19 | ||
20 | if (!path) | ||
21 | return 1; | ||
20 | /* we will overwrite stale pidfile */ | 22 | /* we will overwrite stale pidfile */ |
21 | pid_fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666); | 23 | pid_fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666); |
22 | if (pid_fd < 0) | 24 | if (pid_fd < 0) |
23 | return 0; | 25 | return 0; |
24 | /* few bytes larger, but doesn't use stdio */ | 26 | /* few bytes larger, but doesn't use stdio */ |
25 | end = utoa_to_buf(getpid(), buf, sizeof(buf)); | 27 | end = utoa_to_buf(getpid(), buf, sizeof(buf)); |
26 | end[0] = '\n'; | 28 | *end = '\n'; |
27 | full_write(pid_fd, buf, end - buf + 1); | 29 | full_write(pid_fd, buf, end - buf + 1); |
28 | close(pid_fd); | 30 | close(pid_fd); |
29 | return 1; | 31 | return 1; |