Date: Wed, 08 Sep 2004 10:30:46 +0200 From: Poul-Henning Kamp <phk@phk.freebsd.dk> To: arch@freebsd.org Subject: [BIKESHED] Giving abort(2) a reason Message-ID: <36513.1094632246@critter.freebsd.dk>
next in thread | raw e-mail | index | archive | help
A brief talk about malloc's 'A' option on that channel raised again the idea that we should have a variant of abort(2) which takes a reason which will be logged in the syslog buffers so people can see what is wrong rather than just get a core dump. Given that we are usually pretty stumped when we get to call abort(2) it needs to work without malloc or anything like it and varargs into the kernel is not at all in my future. My proposal therefore is a system call something like: abort2(const char *why, int nargs, void **args); this would terminate the process like abort(2) and in addition produce a message in the syslog buffer along these lines: Aborted $procname pid $pid uid $uid gid $gid. Aborted $procname pid $pid $why $arg1 $arg2... A typical usage would be: if (speed > mach1) { void *msg[2]; msg[0] = speed; msg[1] = mach1; abort2("Supersonic speed not supported", 2, msg); } and the output in syslog would be: Aborted sophwith pid 23 uid 100 gid 100. Aborted sophwith pid 23 Supersonic speed not supported 0x4dd 0x3aa Is this workable ? Anyone want to try their hands at an implementation ? -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?36513.1094632246>