mirror of
https://https.git.savannah.gnu.org/git/diffutils.git
synced 2026-01-28 02:14:40 +00:00
maint: use O_CLOEXEC
* src/cmp.c (main): * src/diff.c (compare_files): * src/dir.c (dir_read): Use O_CLOEXEC when opening files that need not be shared with child processes.
This commit is contained in:
parent
b0215c89b8
commit
7bf02ff2cc
@ -302,7 +302,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
file_desc[f] = open (file[f], O_RDONLY | O_BINARY);
|
||||
file_desc[f] = open (file[f], O_RDONLY | O_BINARY | O_CLOEXEC);
|
||||
|
||||
if (file_desc[f] < 0)
|
||||
{
|
||||
|
||||
@ -1200,7 +1200,7 @@ compare_files (struct comparison const *parent,
|
||||
= file_name_concat (parent->file[1].name, name1, nullptr);
|
||||
}
|
||||
|
||||
int oflags = ((binary ? O_BINARY : 0)
|
||||
int oflags = ((binary ? O_BINARY : 0) | O_CLOEXEC
|
||||
| (no_dereference_symlinks ? O_NOFOLLOW : 0));
|
||||
|
||||
/* For both input files X, if X is at the top level and X can be
|
||||
|
||||
@ -80,7 +80,7 @@ dir_read (int parentdirfd, struct file_data *dir, struct dirdata *dirdata,
|
||||
dirfd = openat (parentdirfd,
|
||||
(parentdirfd < 0 ? dir->name
|
||||
: last_component (dir->name)),
|
||||
(O_RDONLY | O_DIRECTORY
|
||||
(O_RDONLY | O_CLOEXEC | O_DIRECTORY
|
||||
| (no_dereference_symlinks ? O_NOFOLLOW : 0)));
|
||||
if (dirfd < 0)
|
||||
return false;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user