sulogin: make fopen O_CLOEXEC specifier usage portable

The close at exit specifier "e" is glibc extension, so use it only if when
the extension is available.

Proposed-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2016-04-16 15:43:17 +01:00
parent 760e5e682d
commit 400423824a
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
1 changed files with 2 additions and 2 deletions

View File

@ -160,7 +160,7 @@ char *oneline(const char *file)
DBG(dbgprint("reading %s", file));
if (!(fp = fopen(file, "re")))
if (!(fp = fopen(file, "r" UL_CLOEXECSTR)))
return NULL;
len = getline(&ret, &dummy, fp);
if (len >= 0) {
@ -361,7 +361,7 @@ static int detect_consoles_from_proc(struct list_head *consoles)
DBG(dbgprint("trying /proc"));
fc = fopen("/proc/consoles", "re");
fc = fopen("/proc/consoles", "r" UL_CLOEXECSTR);
if (!fc) {
rc = 2;
goto done;