mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Fixed run-parts bug
Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
This commit is contained in:
1 parent
434ec4c533
commit
286711237d
1 file changed
+18
-15
@@ -14,6 +14,7 @@
|
|||||||
#ifdef BUILTIN_RUNPARTS
|
#ifdef BUILTIN_RUNPARTS
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
@@ -127,21 +128,19 @@ int run_parts(char *dir, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
e = readdir(d);
|
if ((e = readdir(d)) == NULL)
|
||||||
if (e) {
|
|
||||||
if (e->d_type == DT_REG) {
|
|
||||||
if (stat(e->d_name, &st))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (st.st_mode & S_IXUSR) {
|
|
||||||
ent[num++] = strdup(e->d_name);
|
|
||||||
if (num >= NUM_SCRIPTS)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (e->d_type == DT_REG) {
|
||||||
|
if (stat(e->d_name, &st))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (st.st_mode & S_IXUSR) {
|
||||||
|
ent[num++] = strdup(e->d_name);
|
||||||
|
if (num >= NUM_SCRIPTS)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
@@ -151,7 +150,11 @@ int run_parts(char *dir, ...)
|
|||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
args[0] = ent[i];
|
args[0] = ent[i];
|
||||||
execv(ent[i], args);
|
if (!fork()) {
|
||||||
|
execv(ent[i], args);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
wait(NULL);
|
||||||
free(ent[i]);
|
free(ent[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user