mirror of
https://github.com/troglobit/finit.git
synced 2026-10-08 00:24:17 +07:00
Use vfork() instead of fork() before exec()
If running on older Linux systems, or any BSD UNIX, vfork() is more efficient when we are about to call exec() anyway. For more info on vfork() vs fork(), see Stack Exchange: http://stackoverflow.com/questions/4259629/what-is-the-difference-between-fork-and-vfork Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -446,7 +446,7 @@ int run(char *cmd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
pid = vfork();
|
||||
if (0 == pid) {
|
||||
int i;
|
||||
FILE *fp;
|
||||
@@ -563,7 +563,7 @@ int run_interactive(char *cmd, char *fmt, ...)
|
||||
|
||||
pid_t run_getty(char *cmd, char *args[], int console)
|
||||
{
|
||||
pid_t pid = fork();
|
||||
pid_t pid = vfork();
|
||||
|
||||
if (!pid) {
|
||||
int i, fd;
|
||||
@@ -629,7 +629,7 @@ pid_t run_getty(char *cmd, char *args[], int console)
|
||||
int run_parts(char *dir, char *cmd)
|
||||
{
|
||||
struct dirent **e;
|
||||
int i, num;
|
||||
volatile int i, num;
|
||||
|
||||
num = scandir(dir, &e, NULL, alphasort);
|
||||
if (num < 0) {
|
||||
@@ -669,7 +669,7 @@ int run_parts(char *dir, char *cmd)
|
||||
}
|
||||
args[j++] = NULL;
|
||||
|
||||
pid = fork();
|
||||
pid = vfork();
|
||||
if (!pid) {
|
||||
_d("Calling %s ...", path);
|
||||
execv(path, args);
|
||||
|
||||
Reference in New Issue
Block a user