aboutgitcodebugslistschat
path: root/pcap.c
diff options
context:
space:
mode:
Diffstat (limited to 'pcap.c')
-rw-r--r--pcap.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/pcap.c b/pcap.c
index e5b8b72..296bbb5 100644
--- a/pcap.c
+++ b/pcap.c
@@ -170,6 +170,7 @@ fail:
*/
void pcap_init(struct ctx *c)
{
+ int flags = O_WRONLY | O_CREAT | O_TRUNC;
struct timeval tv;
if (pcap_fd != -1)
@@ -200,8 +201,8 @@ void pcap_init(struct ctx *c)
strncpy(c->pcap, name, PATH_MAX);
}
- pcap_fd = open(c->pcap, O_WRONLY | O_CREAT | O_TRUNC,
- S_IRUSR | S_IWUSR);
+ flags |= c->foreground ? O_CLOEXEC : 0;
+ pcap_fd = open(c->pcap, flags, S_IRUSR | S_IWUSR);
if (pcap_fd == -1) {
perror("open");
return;