[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Server writing: observations and questions
From: |
Roland McGrath |
Subject: |
Re: Server writing: observations and questions |
Date: |
Fri, 5 Jan 2001 18:21:01 -0500 (EST) |
The GNU `error' function is good for this; see <error.h>. It is takes a
printf format, but also takes an argument that if non-zero is an exit code
(if zero it does not exit) and an argument that if non-zero is an errno
code to print after the formatted message (and a colon). So do:
err = mach_msg (...);
if (err)
{
error (0, err, "mach_msg %s", "blah");
return 1;
}
or if you want to just die:
err = mach_msg (...);
if (err)
error (1, err, "mach_msg %s", "blah");
It will print:
program: mach_msg blah: error string
to stderr.