9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] acidself
@ 2008-11-26 23:54 erik quanstrom
  0 siblings, 0 replies; only message in thread
From: erik quanstrom @ 2008-11-26 23:54 UTC (permalink / raw)
  To: 9fans

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 <u.h>
#include <libc.h>

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("");
}



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-26 23:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-26 23:54 [9fans] acidself erik quanstrom

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).