-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrc.c
More file actions
40 lines (37 loc) · 815 Bytes
/
rc.c
File metadata and controls
40 lines (37 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* rc.c
*
* Part of P-OS init.
*
* Written by Peter Bosch <peterbosc@gmail.com>
*
* Changelog:
* 25-05-2014 - Created
*/
#include "init.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
int execute_rc_scripts()
{
pid_t pid;
int ret_status;
pid = fork();
if (pid) {
pid = waitpid(pid, &ret_status, 0);
if (WIFSIGNALED(ret_status)) {
printf("init: /etc/rc was killed by signal: %s\n", strsignal(WTERMSIG(ret_status)));
return 0;
} else if (WEXITSTATUS(ret_status)) {
printf("init: /etc/rc terminated unsuccessfully with status %i\n", WEXITSTATUS(ret_status));
return 0;
}
return 1;
} else {
execlp(RC_INTERPRETER_PATH, RC_INTERPRETER_NAME, RC_SCRIPT_PATH, NULL);
return 0;//Keep GCC happy
}
}