annotate libpwon/forkoff.c @ 695:8d7dcfd9df53

loadtools: missing #include <unistd.h> in tpinterf modules
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 11 Mar 2020 18:21:22 +0000
parents cef70d53fc5e
children 7d1df6d831e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
571
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
575
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
2 #include <signal.h>
571
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdio.h>
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 #include <stdlib.h>
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <unistd.h>
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 extern char bootctrl_pwon_cmd[];
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 static char shell_pathname[] = "/bin/sh";
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 void
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 fork_exec_pwon_cmd()
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 int i;
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 i = vfork();
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (i < 0) {
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 perror("vfork");
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 exit(1);
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 }
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (i)
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 return;
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 execl(shell_pathname, "sh", "-c", bootctrl_pwon_cmd, (char *) 0);
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 perror(shell_pathname);
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 _exit(1);
41b3e010808d libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }
575
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
27
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
28 pwon_if_needed()
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
29 {
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
30 if (!bootctrl_pwon_cmd[0])
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
31 return(0);
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
32 signal(SIGCHLD, SIG_IGN);
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
33 fork_exec_pwon_cmd();
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
34 return(1);
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
35 }