chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d95a74e
)
CODING_STYLE: mention that dup() should not be used
author
Lennart Poettering
<lennart@poettering.net>
Fri, 3 Apr 2015 12:26:22 +0000
(14:26 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Fri, 3 Apr 2015 12:26:22 +0000
(14:26 +0200)
CODING_STYLE
patch
|
blob
|
history
diff --git
a/CODING_STYLE
b/CODING_STYLE
index 1748dc4bc4d705e33dcf9ac43bac64a8f7727569..feb1a9dd6715ef3731830e99c4b8bf6019d42773 100644
(file)
--- a/
CODING_STYLE
+++ b/
CODING_STYLE
@@
-232,3
+232,10
@@
"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.
"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.