applet_name = tmp_argv[0];
/* Finally we can call NOFORK applet's main() */
rc = applet_main[applet_no](argc, tmp_argv);
+ /* Important for shells: `which CMD` was failing */
+ fflush_all();
} else {
/* xfunc died in NOFORK applet */
}
return wait4pid(rc);
/* child */
+//TODO: prctl(PR_SET_NAME, (long)argv[0], 0, 0, 0);? [think pidof, pgrep, pkill]
+//Rewrite /proc/PID/cmdline? (need to save argv0 and length at init for this to work!)
/* reset some state and run without execing */
/* msg_eol = "\n"; - no caller needs this reinited yet */
/* Maybe we are already re-execed and come here again? */
if (re_execed)
return 0;
+
+ /* fflush_all(); ? - so far all callers had no buffered output to flush */
+
pid = xvfork();
if (pid) /* parent */
return pid;
fd = dup(fd); /* have 0,1,2 open at least to /dev/null */
if (!(flags & DAEMON_ONLY_SANITIZE)) {
+
+ /* fflush_all(); - add it in fork_or_rexec() if necessary */
+
if (fork_or_rexec(argv))
- exit(EXIT_SUCCESS); /* parent */
+ _exit(EXIT_SUCCESS); /* parent */
/* if daemonizing, detach from stdio & ctty */
setsid();
dup2(fd, 0);
* Prevent this: stop being a session leader.
*/
if (fork_or_rexec(argv))
- exit(EXIT_SUCCESS); /* parent */
+ _exit(EXIT_SUCCESS); /* parent */
}
}
while (fd > 2) {