diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2009-07-13 21:26:41 +0000 |
---|---|---|
committer | Mikulas Patocka <mpatocka@redhat.com> | 2009-07-13 21:26:41 +0000 |
commit | 3395d728813d76824f0be66950d39f7758014990 (patch) | |
tree | a5cdcb87fd7adb671cdc5c1447c72f3b047d8ef6 /tools/dmsetup.c | |
parent | f4b2b849049719b704132d87a2c0f62d130e0097 (diff) | |
download | lvm2-3395d728813d76824f0be66950d39f7758014990.tar.gz lvm2-3395d728813d76824f0be66950d39f7758014990.tar.xz lvm2-3395d728813d76824f0be66950d39f7758014990.zip |
Change exit() to _exit() in the child process. exit flushes stdio file buffers,
_exit doesn't. If there were some open files, an error in exec and subsequent
exit() would cause the buffers to be flushed twice.
Example:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
int main()
{
printf("buu");
if (!fork()) {
execl("/bin/true-not-exists", "/bin/true", NULL);
exit(1);
}
wait(NULL);
return 0;
}
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com
---
daemons/dmeventd/libdevmapper-event.c | 2 +-
lib/misc/lvm-exec.c | 2 +-
test/harness.c | 3 ++-
tools/dmsetup.c | 2 +-
4 files changed, 5 insertions(+), 4 deletions(-)
Diffstat (limited to 'tools/dmsetup.c')
-rw-r--r-- | tools/dmsetup.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 3582e4a1..94ac9fd8 100644 --- a/tools/dmsetup.c +++ b/tools/dmsetup.c @@ -1055,7 +1055,7 @@ static int _exec_command(const char *name) if (!(pid = fork())) { execvp(args[0], args); - exit(127); + _exit(127); } else if (pid < (pid_t) 0) return 0; |