Changeset View
Changeset View
Standalone View
Standalone View
bin/sh/input.c
Show First 20 Lines • Show All 354 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
void | void | ||||
setinputfile(const char *fname, int push) | setinputfile(const char *fname, int push) | ||||
{ | { | ||||
int e; | int e; | ||||
int fd; | int fd; | ||||
int fd2; | int fd2; | ||||
int oflags = O_RDONLY | O_CLOEXEC; | |||||
if (verifyflag) | |||||
oflags |= O_VERIFY; | |||||
INTOFF; | INTOFF; | ||||
if ((fd = open(fname, O_RDONLY | O_CLOEXEC)) < 0) { | if ((fd = open(fname, oflags)) < 0) { | ||||
e = errno; | e = errno; | ||||
errorwithstatus(e == ENOENT || e == ENOTDIR ? 127 : 126, | errorwithstatus(e == ENOENT || e == ENOTDIR ? 127 : 126, | ||||
"cannot open %s: %s", fname, strerror(e)); | "cannot open %s: %s", fname, strerror(e)); | ||||
} | } | ||||
if (fd < 10) { | if (fd < 10) { | ||||
fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 10); | fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 10); | ||||
close(fd); | close(fd); | ||||
if (fd2 < 0) | if (fd2 < 0) | ||||
▲ Show 20 Lines • Show All 147 Lines • Show Last 20 Lines |