All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Open file with O_CLOEXEC to avoid fd leak
@ 2020-01-19  3:50 mingli.yu
  2020-01-19  4:02 ` ✗ patchtest: failure for " Patchwork
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: mingli.yu @ 2020-01-19  3:50 UTC (permalink / raw)
  To: openembedded-core, seebs; +Cc: pavelmn

From: Pavel Modilaynen <pavelmn@axis.com>

Use close-on-exec (O_CLOEXEC) flag when open log file to
make sure its file descriptor is not leaked to parent
process on fork/exec.
---
 pseudo_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pseudo_util.c b/pseudo_util.c
index c867ed6..0ec527b 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -1594,7 +1594,7 @@ pseudo_logfile(char *filename, char *defname, int prefer_fd) {
 		}
 		free(filename);
 	}	
-	fd = open(pseudo_path, O_WRONLY | O_APPEND | O_CREAT, 0644);
+	fd = open(pseudo_path, O_WRONLY | O_APPEND | O_CREAT | O_CLOEXEC, 0644);
 	if (fd == -1) {
 		pseudo_diag("help: can't open log file %s: %s\n", pseudo_path, strerror(errno));
 	} else {
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-01-20  3:27 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-19  3:50 [PATCH] Open file with O_CLOEXEC to avoid fd leak mingli.yu
2020-01-19  4:02 ` ✗ patchtest: failure for " Patchwork
2020-01-19  4:12 ` [PATCH v2] " mingli.yu
2020-01-19  4:32 ` ✗ patchtest: failure for Open file with O_CLOEXEC to avoid fd leak (rev2) Patchwork
2020-01-19  5:15 ` [PATCH v3] pseudo_util.c: Open file with O_CLOEXEC to avoid fd leak mingli.yu
2020-01-19  5:32 ` ✗ patchtest: failure for Open file with O_CLOEXEC to avoid fd leak (rev3) Patchwork
2020-01-19  5:41   ` Yu, Mingli
2020-01-20  1:29     ` Paul Eggleton
2020-01-20  1:34       ` Yu, Mingli
2020-01-20  2:28         ` Peter Kjellerstedt
2020-01-20  3:04           ` Yu, Mingli
2020-01-20  3:15             ` Peter Kjellerstedt
2020-01-20  3:27               ` [pseudo v4] pseudo_util.c: Open file with O_CLOEXEC to avoid fd leak mingli.yu
2020-01-20  3:27               ` ✗ patchtest: failure for Open file with O_CLOEXEC to avoid fd leak (rev3) Yu, Mingli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.