diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-17 14:28:53 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-17 14:28:53 +0000 |
| commit | cb448fe01bbe75ef31c3190e8b63b0e1a320ffb4 (patch) | |
| tree | 9757477193c1b8f3be9a772cabfb1ef92639240e /libbb | |
| parent | ffae845cfd0a0b9872827d806984841d4cfee104 (diff) | |
| download | busybox-w32-cb448fe01bbe75ef31c3190e8b63b0e1a320ffb4.tar.gz busybox-w32-cb448fe01bbe75ef31c3190e8b63b0e1a320ffb4.tar.bz2 busybox-w32-cb448fe01bbe75ef31c3190e8b63b0e1a320ffb4.zip | |
libbb: introduce and use xrename and rename_or_warn.
Diffstat (limited to 'libbb')
| -rw-r--r-- | libbb/vfork_daemon_rexec.c | 5 | ||||
| -rw-r--r-- | libbb/xfuncs.c | 26 |
2 files changed, 20 insertions, 11 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 98339c930..1567d89be 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
| @@ -98,11 +98,6 @@ int wait4pid(int pid) | |||
| 98 | if (WIFSIGNALED(status)) | 98 | if (WIFSIGNALED(status)) |
| 99 | return WTERMSIG(status) + 1000; | 99 | return WTERMSIG(status) + 1000; |
| 100 | return 0; | 100 | return 0; |
| 101 | if (WIFEXITED(status)) | ||
| 102 | return WEXITSTATUS(status); | ||
| 103 | if (WIFSIGNALED(status)) | ||
| 104 | return WTERMSIG(status) + 1000; | ||
| 105 | return 0; | ||
| 106 | } | 101 | } |
| 107 | 102 | ||
| 108 | #if ENABLE_FEATURE_PREFER_APPLETS | 103 | #if ENABLE_FEATURE_PREFER_APPLETS |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index 8dd414d6a..b4c059f20 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
| @@ -146,18 +146,32 @@ int open_or_warn(const char *pathname, int flags) | |||
| 146 | return open3_or_warn(pathname, flags, 0666); | 146 | return open3_or_warn(pathname, flags, 0666); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | void xpipe(int filedes[2]) | ||
| 150 | { | ||
| 151 | if (pipe(filedes)) | ||
| 152 | bb_perror_msg_and_die("can't create pipe"); | ||
| 153 | } | ||
| 154 | |||
| 155 | void xunlink(const char *pathname) | 149 | void xunlink(const char *pathname) |
| 156 | { | 150 | { |
| 157 | if (unlink(pathname)) | 151 | if (unlink(pathname)) |
| 158 | bb_perror_msg_and_die("can't remove file '%s'", pathname); | 152 | bb_perror_msg_and_die("can't remove file '%s'", pathname); |
| 159 | } | 153 | } |
| 160 | 154 | ||
| 155 | void xrename(const char *oldpath, const char *newpath) | ||
| 156 | { | ||
| 157 | if (rename(oldpath, newpath)) | ||
| 158 | bb_perror_msg_and_die("can't move '%s' to '%s'", oldpath, newpath); | ||
| 159 | } | ||
| 160 | |||
| 161 | int rename_or_warn(const char *oldpath, const char *newpath) | ||
| 162 | { | ||
| 163 | int n = rename(oldpath, newpath); | ||
| 164 | if (n) | ||
| 165 | bb_perror_msg("can't move '%s' to '%s'", oldpath, newpath); | ||
| 166 | return n; | ||
| 167 | } | ||
| 168 | |||
| 169 | void xpipe(int filedes[2]) | ||
| 170 | { | ||
| 171 | if (pipe(filedes)) | ||
| 172 | bb_perror_msg_and_die("can't create pipe"); | ||
| 173 | } | ||
| 174 | |||
| 161 | // Turn on nonblocking I/O on a fd | 175 | // Turn on nonblocking I/O on a fd |
| 162 | int ndelay_on(int fd) | 176 | int ndelay_on(int fd) |
| 163 | { | 177 | { |
