* aux/trampoline patch
@ 2020-03-27 2:07 Alex Musolino
0 siblings, 0 replies; only message in thread
From: Alex Musolino @ 2020-03-27 2:07 UTC (permalink / raw)
To: 9front
Hello,
The intent of this patch is to fix a couple quirks of aux/trampoline
that I don't particularly like. Firstly, when running aux/trampoline
interactively, it can't be killed with DEL. Secondly, deleting the
rio window it was invoked from leaves it running.
Thoughts? Now that I think of it, perhaps the parent proc should
forward any notes it receives to its children...
diff -r d416b601a9df sys/src/cmd/aux/trampoline.c
--- a/sys/src/cmd/aux/trampoline.c Thu Mar 26 18:24:39 2020 +1030
+++ b/sys/src/cmd/aux/trampoline.c Fri Mar 27 12:29:43 2020 +1030
@@ -9,6 +9,8 @@
Maxpath= 128,
};
+char notestr[] = "die yankee pig dog";
+
typedef struct Endpoints Endpoints;
struct Endpoints
{
@@ -37,6 +39,7 @@
main(int argc, char **argv)
{
char *altaddr, *checkmac, *mac;
+ int c1, c2;
int fd, fd0, fd1;
void (*x)(int, int);
Endpoints *ep;
@@ -83,19 +86,27 @@
if(fd < 0)
sysfatal("dial %s: %r", argv[0]);
- rfork(RFNOTEG);
- switch(fork()){
+ switch(c1 = fork()){
case -1:
fprint(2, "%s: fork: %r\n", argv0);
exits("dial");
case 0:
(*x)(fd0, fd);
- break;
- default:
+ exits(0);
+ }
+
+ switch(c2 = fork()){
+ case -1:
+ fprint(2, "%s: fork: %r\n", argv0);
+ exits("dial");
+ case 0:
(*x)(fd, fd1);
- break;
+ exits(0);
}
- postnote(PNGROUP, getpid(), "die yankee pig dog");
+
+ waitpid();
+ postnote(PNPROC, c1, notestr);
+ postnote(PNPROC, c2, notestr);
exits(0);
}
--
Cheers,
Alex Musolino
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-03-27 2:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 2:07 aux/trampoline patch Alex Musolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).