FreeCalypso > hg > freecalypso-tools
annotate libpwon/forkoff.c @ 771:9c1d580b50fb
simagent: Rx byte timeout test implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 12 Mar 2021 20:39:18 +0000 |
parents | 7d1df6d831e4 |
children | ab54957dbe35 |
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[]; |
736
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
8 extern int bootctrl_duart28c_mode; |
571
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 static char shell_pathname[] = "/bin/sh"; |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 void |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 fork_exec_pwon_cmd() |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 { |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int i; |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 i = vfork(); |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (i < 0) { |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 perror("vfork"); |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 exit(1); |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 } |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (i) |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return; |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 execl(shell_pathname, "sh", "-c", bootctrl_pwon_cmd, (char *) 0); |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 perror(shell_pathname); |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 _exit(1); |
41b3e010808d
libpwon started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
575
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
571
diff
changeset
|
28 |
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
571
diff
changeset
|
29 pwon_if_needed() |
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
571
diff
changeset
|
30 { |
736
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
31 if (bootctrl_duart28c_mode) { |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
32 signal(SIGCHLD, SIG_IGN); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
33 fork_duart28c_pulse(); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
34 return(1); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
35 } |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
36 if (bootctrl_pwon_cmd[0]) { |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
37 signal(SIGCHLD, SIG_IGN); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
38 fork_exec_pwon_cmd(); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
39 return(1); |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
40 } |
7d1df6d831e4
libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents:
575
diff
changeset
|
41 return(0); |
575
cef70d53fc5e
loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
571
diff
changeset
|
42 } |