X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=CODING_STYLE;h=feb1a9dd6715ef3731830e99c4b8bf6019d42773;hp=b687e729f4676c3c91ce054eeced49322a4e339f;hb=92947a0878c5d129adb37ddbfdef35274ef5c6ae;hpb=918315e457ca36cab94ff3b6060e143968c99ace diff --git a/CODING_STYLE b/CODING_STYLE index b687e729f..feb1a9dd6 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -226,3 +226,16 @@ instead of just this: unlink("/foo/bar/baz"); + +- Don't invoke exit(), ever. It is not replacement for proper error + handling. Please escalate errors up your call chain, and use normal + "return" to exit from the main function of a process. If you + fork()ed off a child process, please use _exit() instead of exit(), + so that the exit handlers are not run. + +- Please never use dup(). Use fcntl(fd, F_DUPFD_CLOEXEC, 3) + instead. For two reason: first, you want O_CLOEXEC set on the new fd + (see above). Second, dup() will happily duplicate your fd as 0, 1, + 2, i.e. stdin, stdout, stderr, should those fds be closed. Given the + special semantics of those fds, it's probably a good idea to avoid + them. F_DUPFD_CLOEXEC with "3" as parameter avoids them.