Duplicate logging fd, so it can be used from child process
This commit is contained in:
parent
a1c0cbacbd
commit
341832d755
@ -222,9 +222,11 @@ static bool containPassFd(struct nsjconf_t *nsjconf, int fd)
|
||||
|
||||
static bool containMakeFdsCOENaive(struct nsjconf_t *nsjconf)
|
||||
{
|
||||
// Don't use getrlimit(RLIMIT_NOFILE) here, as it can return an artifically small value
|
||||
// (e.g. 32), which could be smaller than a maximum assigned number to file-descriptors
|
||||
// in this process. Just use some reasonably sane value (e.g. 1024)
|
||||
/*
|
||||
* Don't use getrlimit(RLIMIT_NOFILE) here, as it can return an artifically small value
|
||||
* (e.g. 32), which could be smaller than a maximum assigned number to file-descriptors
|
||||
* in this process. Just use some reasonably sane value (e.g. 1024)
|
||||
*/
|
||||
for (unsigned fd = 0; fd < 1024; fd++) {
|
||||
int flags = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD, 0));
|
||||
if (flags == -1) {
|
||||
|
2
log.c
2
log.c
@ -52,7 +52,7 @@ bool logInitLogFile(struct nsjconf_t *nsjconf, const char *logfile, bool is_verb
|
||||
logfile = _LOG_DEFAULT_FILE;
|
||||
}
|
||||
if (logfile == NULL) {
|
||||
log_fd = STDERR_FILENO;
|
||||
log_fd = fcntl(log_fd, F_DUPFD_CLOEXEC);
|
||||
} else {
|
||||
if (TEMP_FAILURE_RETRY(log_fd = open(logfile, O_CREAT | O_RDWR | O_APPEND, 0640)) ==
|
||||
-1) {
|
||||
|
@ -87,7 +87,10 @@ static int subprocNewProc(struct nsjconf_t *nsjconf, int fd_in, int fd_out, int
|
||||
putenv(p->val);
|
||||
}
|
||||
|
||||
LOG_D("Trying to execve('%s')", nsjconf->argv[0]);
|
||||
char cs_addr[64];
|
||||
netConnToText(fd_in, true /* remote */ , cs_addr, sizeof(cs_addr), NULL);
|
||||
LOG_I("Executing '%s' for '%s'", nsjconf->argv[0], cs_addr);
|
||||
|
||||
for (size_t i = 0; nsjconf->argv[i]; i++) {
|
||||
LOG_D(" Arg[%zu]: '%s'", i, nsjconf->argv[i]);
|
||||
}
|
||||
@ -393,7 +396,6 @@ void subprocRunChild(struct nsjconf_t *nsjconf, int fd_in, int fd_out, int fd_er
|
||||
close(parent_fd);
|
||||
char cs_addr[64];
|
||||
netConnToText(fd_in, true /* remote */ , cs_addr, sizeof(cs_addr), NULL);
|
||||
LOG_I("PID: %d about to execute '%s' for %s", pid, nsjconf->argv[0], cs_addr);
|
||||
}
|
||||
|
||||
int subprocSystem(const char **argv, char **env)
|
||||
|
Loading…
Reference in New Issue
Block a user