annotate libpwon/forkoff.c @ 964:a96cb97b66a2

ringtools/imy: fix duplicate definition of tdma_durations[] The bug was reported by Vadim Yanitskiy <fixeria@osmocom.org>, although the present fix is slightly different from the contributed patch: because main.c doesn't need this tdma_durations[] array at all, let's simply remove the reference to this array from main.c rather than turn it into an extern. I no longer remember my original thought flow that resulted (by mistake) in tdma_durations[] being multiply defined in main.c and durations.c. My intent might have been to define all globals in main.c and have the reference in durations.c be an extern - and I missed that extern - but without clear memory, I have no certainty. In any case, having this data array defined in the same module that fills it (durations.c) is sensible, so let's make it the new way.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 31 Aug 2023 19:38:18 +0000
parents ab54957dbe35
children
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[];
953
ab54957dbe35 libpwon: implement -Petmoff mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 736
diff changeset
8 extern int bootctrl_duart28c_mode, bootctrl_etmoff_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 }
953
ab54957dbe35 libpwon: implement -Petmoff mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 736
diff changeset
41 if (bootctrl_etmoff_mode) {
ab54957dbe35 libpwon: implement -Petmoff mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 736
diff changeset
42 bootctrl_do_etmoff();
ab54957dbe35 libpwon: implement -Petmoff mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 736
diff changeset
43 return(2);
ab54957dbe35 libpwon: implement -Petmoff mode
Mychaela Falconia <falcon@freecalypso.org>
parents: 736
diff changeset
44 }
736
7d1df6d831e4 libpwon: added -Pdtr and -Prts support for DUART28C
Mychaela Falconia <falcon@freecalypso.org>
parents: 575
diff changeset
45 return(0);
575
cef70d53fc5e loadtools: new -P boot control mechanism implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 571
diff changeset
46 }