diff options
author | Karel Zak | 2006-12-07 00:26:05 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:26:05 +0100 |
commit | 95f1bdeee42cd7b9ac49d64b27bcec49557a991e (patch) | |
tree | 5813d335771188c724c3d1bc9f9f9feb23c1d9ca /login-utils | |
parent | Imported from util-linux-2.11w tarball. (diff) | |
download | kernel-qcow2-util-linux-95f1bdeee42cd7b9ac49d64b27bcec49557a991e.tar.gz kernel-qcow2-util-linux-95f1bdeee42cd7b9ac49d64b27bcec49557a991e.tar.xz kernel-qcow2-util-linux-95f1bdeee42cd7b9ac49d64b27bcec49557a991e.zip |
Imported from util-linux-2.11x tarball.
Diffstat (limited to 'login-utils')
-rw-r--r-- | login-utils/setpwnam.c | 2 | ||||
-rw-r--r-- | login-utils/simpleinit.c | 16 |
2 files changed, 14 insertions, 4 deletions
diff --git a/login-utils/setpwnam.c b/login-utils/setpwnam.c index 62d47a51c..5a46863a8 100644 --- a/login-utils/setpwnam.c +++ b/login-utils/setpwnam.c @@ -98,7 +98,7 @@ setpwnam (struct passwd *pwd) /* sanity check */ for (x = 0; x < 3; x++) { if (x > 0) sleep(1); - fd = open(PTMPTMP_FILE, O_WRONLY|O_CREAT, 0644); + fd = open(PTMPTMP_FILE, O_WRONLY|O_CREAT|O_EXCL, 0644); if (fd == -1) { umask(oldumask); return -1; diff --git a/login-utils/simpleinit.c b/login-utils/simpleinit.c index 1b4fbcbeb..cf33fe146 100644 --- a/login-utils/simpleinit.c +++ b/login-utils/simpleinit.c @@ -289,9 +289,12 @@ int main(int argc, char *argv[]) for(i = 0; i < numcmd; i++) { if(pid == inittab[i].pid || inittab[i].pid < 0) { - if(stopped) inittab[i].pid = -1; - else spawn(i); - break; + if (stopped) + inittab[i].pid = -1; + else + spawn(i); + if (pid == inittab[i].pid) + break; } } } @@ -456,9 +459,16 @@ static void spawn (int i) struct timeval ct; if (inittab[i].toks[0] == NULL) return; + /* Check if respawning too fast */ gettimeofday (&ct, NULL); ds_taken = ct.tv_sec - inittab[i].last_start.tv_sec; + + /* On the first iteration last_start==0 and ds_taken + may be very large. Avoid overflow. -- Denis Vlasenko */ + if (ds_taken > 10000) + ds_taken = 10000; + ds_taken *= 10; ds_taken += (ct.tv_usec - inittab[i].last_start.tv_usec) / 100000; if (ds_taken < 1) |