From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: erik quanstrom Date: Wed, 26 Nov 2008 18:54:17 -0500 To: 9fans@9fans.net MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: [9fans] acidself Topicbox-Message-UUID: 5341012e-ead4-11e9-9d60-3106f5b1d025 i hope this is worth a few tens of microseconds of amusement. the problem is this. how to get a backtrace when you may be killed by your parent who is cleaning up after himself before somone wielding a debugger has a chance to react? the amusing answer is just run acid yourself. how? well just catch the note. sleazy, no? think of it as one more reason to enjoy plan 9. - erik ---- ; cat /rc/bin/stk #!/bin/rc for(i) echo 'stk()' | acid $i ---- #include #include void system(char *cmd, char **av) { int in, pid; switch(pid=fork()){ case -1: return; case 0: in = open("/dev/null", OREAD); close(0); dup(in, 0); exec(cmd, av); _exits(0); default: while(waitpid() < 0) postnote(PNPROC, pid, "die"); break; } } void acid(void) { char *av[3], buf[16]; snprint(buf, sizeof buf, "%d", getpid()); av[0] = "stk"; av[1] = buf; av[2] = 0; system("/bin/stk", av); } int an(void*, char*) { acid(); return 0; } void main(void) { atnotify(an, 1); abort(); exits(""); }