diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-18 22:03:26 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-11-18 22:03:26 +0000 |
commit | 8c464c6dfa6a2fe87ca2762a237811b3ce2a8730 (patch) | |
tree | cbc4d021bafef2561cbb37ea0d0c955bfd985401 /networking/udhcp/pidfile.c | |
parent | c8165735884970b3e349cd847d6dc923e3e2d006 (diff) | |
download | busybox-w32-8c464c6dfa6a2fe87ca2762a237811b3ce2a8730.tar.gz busybox-w32-8c464c6dfa6a2fe87ca2762a237811b3ce2a8730.tar.bz2 busybox-w32-8c464c6dfa6a2fe87ca2762a237811b3ce2a8730.zip |
small fixes: using fd-based io instead of FILE*-based,
missed O_TRUNC, etc
git-svn-id: svn://busybox.net/trunk/busybox@16579 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to '')
-rw-r--r-- | networking/udhcp/pidfile.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/networking/udhcp/pidfile.c b/networking/udhcp/pidfile.c index 8d00490af..bcb2608c5 100644 --- a/networking/udhcp/pidfile.c +++ b/networking/udhcp/pidfile.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "common.h" | 23 | #include "common.h" |
24 | 24 | ||
25 | 25 | ||
26 | static char *saved_pidfile; | 26 | static const char *saved_pidfile; |
27 | 27 | ||
28 | static void pidfile_delete(void) | 28 | static void pidfile_delete(void) |
29 | { | 29 | { |
@@ -36,14 +36,14 @@ int pidfile_acquire(const char *pidfile) | |||
36 | int pid_fd; | 36 | int pid_fd; |
37 | if (!pidfile) return -1; | 37 | if (!pidfile) return -1; |
38 | 38 | ||
39 | pid_fd = open(pidfile, O_CREAT | O_WRONLY, 0644); | 39 | pid_fd = open(pidfile, O_CREAT|O_WRONLY|O_TRUNC, 0644); |
40 | if (pid_fd < 0) { | 40 | if (pid_fd < 0) { |
41 | bb_perror_msg("unable to open pidfile %s", pidfile); | 41 | bb_perror_msg("cannot open pidfile %s", pidfile); |
42 | } else { | 42 | } else { |
43 | lockf(pid_fd, F_LOCK, 0); | 43 | lockf(pid_fd, F_LOCK, 0); |
44 | if (!saved_pidfile) | 44 | if (!saved_pidfile) |
45 | atexit(pidfile_delete); | 45 | atexit(pidfile_delete); |
46 | saved_pidfile = (char *) pidfile; | 46 | saved_pidfile = pidfile; |
47 | } | 47 | } |
48 | 48 | ||
49 | return pid_fd; | 49 | return pid_fd; |