[BIKESHED] Giving abort(2) a reason

Poul-Henning Kamp phk at phk.freebsd.dk
Wed Sep 8 01:30:49 PDT 2004


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


More information about the freebsd-arch mailing list