chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util: fix space calculation in get_process_cmdline()
[elogind.git]
/
src
/
execute.c
diff --git
a/src/execute.c
b/src/execute.c
index d5bb8d3602920510e3fdb4e46db6a6d544f9b612..2acb11192d45f44d40b0c9aaf9028a2d73c3c38b 100644
(file)
--- a/
src/execute.c
+++ b/
src/execute.c
@@
-197,7
+197,7
@@
static int connect_logger_as(const ExecContext *context, ExecOutput output, cons
output == EXEC_OUTPUT_KMSG ? "kmsg" : "syslog",
context->syslog_priority,
context->syslog_identifier ? context->syslog_identifier : ident,
output == EXEC_OUTPUT_KMSG ? "kmsg" : "syslog",
context->syslog_priority,
context->syslog_identifier ? context->syslog_identifier : ident,
-
!context->syslog_no
_prefix);
+
context->syslog_level
_prefix);
if (fd != nfd) {
r = dup2(fd, nfd) < 0 ? -errno : nfd;
if (fd != nfd) {
r = dup2(fd, nfd) < 0 ? -errno : nfd;
@@
-964,17
+964,26
@@
int exec_spawn(ExecCommand *command,
goto fail;
}
goto fail;
}
- if (!context->
no_setsid
)
+ if (!context->
same_pgrp
)
if (setsid() < 0) {
r = EXIT_SETSID;
goto fail;
}
if (setsid() < 0) {
r = EXIT_SETSID;
goto fail;
}
- if (socket_fd >= 0 && context->tcpwrap_name)
- if (!socket_tcpwrap(socket_fd, context->tcpwrap_name)) {
- r = EXIT_TCPWRAP;
- goto fail;
+ if (context->tcpwrap_name) {
+ if (socket_fd >= 0)
+ if (!socket_tcpwrap(socket_fd, context->tcpwrap_name)) {
+ r = EXIT_TCPWRAP;
+ goto fail;
+ }
+
+ for (i = 0; i < (int) n_fds; i++) {
+ if (!socket_tcpwrap(fds[i], context->tcpwrap_name)) {
+ r = EXIT_TCPWRAP;
+ goto fail;
+ }
}
}
+ }
if (confirm_spawn) {
char response;
if (confirm_spawn) {
char response;
@@
-1062,8
+1071,8
@@
int exec_spawn(ExecCommand *command,
}
}
}
}
- if (context->cpu
_affinity_
set)
- if (sched_setaffinity(0,
sizeof(context->cpu_affinity), &context->cpu_affinity
) < 0) {
+ if (context->cpuset)
+ if (sched_setaffinity(0,
CPU_ALLOC_SIZE(context->cpuset_ncpus), context->cpuset
) < 0) {
r = EXIT_CPUAFFINITY;
goto fail;
}
r = EXIT_CPUAFFINITY;
goto fail;
}
@@
-1074,8
+1083,8
@@
int exec_spawn(ExecCommand *command,
goto fail;
}
goto fail;
}
- if (context->timer_slack_ns_set)
- if (prctl(PR_SET_TIMERSLACK, context->timer_slack_ns
_set
) < 0) {
+ if (context->timer_slack_ns
ec
_set)
+ if (prctl(PR_SET_TIMERSLACK, context->timer_slack_ns
ec
) < 0) {
r = EXIT_TIMERSLACK;
goto fail;
}
r = EXIT_TIMERSLACK;
goto fail;
}
@@
-1272,8
+1281,7
@@
int exec_spawn(ExecCommand *command,
log_debug("Forked %s as %lu", command->path, (unsigned long) pid);
log_debug("Forked %s as %lu", command->path, (unsigned long) pid);
- command->exec_status.pid = pid;
- command->exec_status.start_timestamp = now(CLOCK_REALTIME);
+ exec_status_start(&command->exec_status, pid);
*ret = pid;
return 0;
*ret = pid;
return 0;
@@
-1286,6
+1294,7
@@
void exec_context_init(ExecContext *c) {
c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0);
c->cpu_sched_policy = SCHED_OTHER;
c->syslog_priority = LOG_DAEMON|LOG_INFO;
c->ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 0);
c->cpu_sched_policy = SCHED_OTHER;
c->syslog_priority = LOG_DAEMON|LOG_INFO;
+ c->syslog_level_prefix = true;
c->mount_flags = MS_SHARED;
}
c->mount_flags = MS_SHARED;
}
@@
-1341,6
+1350,9
@@
void exec_context_done(ExecContext *c) {
strv_free(c->inaccessible_dirs);
c->inaccessible_dirs = NULL;
strv_free(c->inaccessible_dirs);
c->inaccessible_dirs = NULL;
+
+ if (c->cpuset)
+ CPU_FREE(c->cpuset);
}
void exec_command_done(ExecCommand *c) {
}
void exec_command_done(ExecCommand *c) {
@@
-1449,16
+1461,16
@@
void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
prefix, c->cpu_sched_priority,
prefix, yes_no(c->cpu_sched_reset_on_fork));
prefix, c->cpu_sched_priority,
prefix, yes_no(c->cpu_sched_reset_on_fork));
- if (c->cpu
_affinity_
set) {
+ if (c->cpuset) {
fprintf(f, "%sCPUAffinity:", prefix);
fprintf(f, "%sCPUAffinity:", prefix);
- for (i = 0; i <
CPU_SETSIZE
; i++)
- if (CPU_ISSET
(i, &c->cpu_affinity
))
+ for (i = 0; i <
c->cpuset_ncpus
; i++)
+ if (CPU_ISSET
_S(i, CPU_ALLOC_SIZE(c->cpuset_ncpus), c->cpuset
))
fprintf(f, " %i", i);
fputs("\n", f);
}
fprintf(f, " %i", i);
fputs("\n", f);
}
- if (c->timer_slack_ns_set)
- fprintf(f, "%sTimerSlackNS
: %lu\n", prefix, c->timer_slack_ns
);
+ if (c->timer_slack_ns
ec
_set)
+ fprintf(f, "%sTimerSlackNS
ec: %lu\n", prefix, c->timer_slack_nsec
);
fprintf(f,
"%sStandardInput: %s\n"
fprintf(f,
"%sStandardInput: %s\n"
@@
-1549,11
+1561,23
@@
void exec_context_dump(ExecContext *c, FILE* f, const char *prefix) {
}
}
}
}
-void exec_status_
fill(ExecStatus *s, pid_t pid, int code, int status
) {
+void exec_status_
start(ExecStatus *s, pid_t pid
) {
assert(s);
assert(s);
+ zero(*s);
+ s->pid = pid;
+ dual_timestamp_get(&s->start_timestamp);
+}
+
+void exec_status_exit(ExecStatus *s, pid_t pid, int code, int status) {
+ assert(s);
+
+ if ((s->pid && s->pid != pid) ||
+ !s->start_timestamp.realtime <= 0)
+ zero(*s);
+
s->pid = pid;
s->pid = pid;
-
s->exit_timestamp = now(CLOCK_REALTIME
);
+
dual_timestamp_get(&s->exit_timestamp
);
s->code = code;
s->status = status;
s->code = code;
s->status = status;
@@
-1575,17
+1599,17
@@
void exec_status_dump(ExecStatus *s, FILE *f, const char *prefix) {
"%sPID: %lu\n",
prefix, (unsigned long) s->pid);
"%sPID: %lu\n",
prefix, (unsigned long) s->pid);
- if (s->start_timestamp > 0)
+ if (s->start_timestamp
.realtime
> 0)
fprintf(f,
"%sStart Timestamp: %s\n",
fprintf(f,
"%sStart Timestamp: %s\n",
- prefix, format_timestamp(buf, sizeof(buf), s->start_timestamp));
+ prefix, format_timestamp(buf, sizeof(buf), s->start_timestamp
.realtime
));
- if (s->exit_timestamp > 0)
+ if (s->exit_timestamp
.realtime
> 0)
fprintf(f,
"%sExit Timestamp: %s\n"
"%sExit Code: %s\n"
"%sExit Status: %i\n",
fprintf(f,
"%sExit Timestamp: %s\n"
"%sExit Code: %s\n"
"%sExit Status: %i\n",
- prefix, format_timestamp(buf, sizeof(buf), s->exit_timestamp),
+ prefix, format_timestamp(buf, sizeof(buf), s->exit_timestamp
.realtime
),
prefix, sigchld_code_to_string(s->code),
prefix, s->status);
}
prefix, sigchld_code_to_string(s->code),
prefix, s->status);
}