diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-03-30 17:45:56 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-03-30 17:45:56 +0200 |
commit | 733f728b8fb4a5cc823c347c0f4bb6a0a2d4b748 (patch) | |
tree | 0684bdab15a8dc2eef18c8b1bf09390bd8d83f80 | |
parent | acf6d421f5be7e20e13cfa5003b31b4afb527b8c (diff) |
fork: call getpid() only once
-rw-r--r-- | src/fork-detect.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/fork-detect.c b/src/fork-detect.c index d416eb3..20ee1ab 100644 --- a/src/fork-detect.c +++ b/src/fork-detect.c @@ -31,7 +31,7 @@ int ca_detect_fork(void) { static volatile pid_t pid = (pid_t) -1; - pid_t v; + pid_t v, we; /* Some really stupid applications (Hey, vim, that means you!) * love to fork after initializing gtk/libcanberra. This is really @@ -43,9 +43,10 @@ int ca_detect_fork(void) { * and this is not exactly crucial, so we don't care */ v = pid; + we = getpid(); - if (v == getpid() || v == (pid_t) -1) { - pid = getpid(); + if (v == we || v == (pid_t) -1) { + pid = we; return 0; } |