NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/60764: err(3): unclear whether exit or _exit



>Number:         60764
>Category:       lib
>Synopsis:       err(3): unclear whether exit or _exit
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 22 12:45:00 +0000 2026
>Originator:     Taylor R Campbell
>Release:        current, 11, 10, ...
>Organization:
The ErrorBSD Exitation, Inc.
>Environment:
>Description:

	The man page says:

	> The err(), verr(), errc(), verrc(), errx(), and verrx()
	> functions do not return, but instead cause the program to
	> terminate with the status value given by the argument status.
	> It is often appropriate to use the value EXIT_FAILURE,
	> defined in <stdlib.h>, as the status argument given to these
	> functions.

	But do they run atexit() functions and destructors?

	This isn't clear from the man page, but by code inspection,
	they appears to:

     57 __dead void
     58 verrc(int eval, int code, const char *fmt, va_list ap)
     59 {
     60 	(void)fprintf(stderr, "%s: ", getprogname());
     61 	if (fmt != NULL) {
     62 		(void)vfprintf(stderr, fmt, ap);
     63 		(void)fprintf(stderr, ": ");
     64 	}
     65 	(void)fprintf(stderr, "%s\n", strerror(code));
 ==> 66 	exit(eval);
     67 }

	https://nxr.netbsd.org/xref/src/lib/libc/gen/verrc.c?r=1.3#66

>How-To-Repeat:

	man page inspection

>Fix:

	1. Clarify the man page.
	2. Consider adding variants that use _exit instead?  E.g., for
	   use in child processes.




Home | Main Index | Thread Index | Old Index