mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
core: also set $SYSTEMD_EXEC_PID= for generators
This commit is contained in:
parent
cfd1c6e262
commit
43f565c677
@ -4105,7 +4105,8 @@ static int manager_run_environment_generators(Manager *m) {
|
||||
|
||||
RUN_WITH_UMASK(0022)
|
||||
r = execute_directories((const char* const*) paths, DEFAULT_TIMEOUT_USEC, gather_environment,
|
||||
args, NULL, m->transient_environment, EXEC_DIR_PARALLEL | EXEC_DIR_IGNORE_ERRORS);
|
||||
args, NULL, m->transient_environment,
|
||||
EXEC_DIR_PARALLEL | EXEC_DIR_IGNORE_ERRORS | EXEC_DIR_SET_SYSTEMD_EXEC_PID);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -4140,7 +4141,8 @@ static int manager_run_generators(Manager *m) {
|
||||
|
||||
RUN_WITH_UMASK(0022)
|
||||
(void) execute_directories((const char* const*) paths, DEFAULT_TIMEOUT_USEC, NULL, NULL,
|
||||
(char**) argv, m->transient_environment, EXEC_DIR_PARALLEL | EXEC_DIR_IGNORE_ERRORS);
|
||||
(char**) argv, m->transient_environment,
|
||||
EXEC_DIR_PARALLEL | EXEC_DIR_IGNORE_ERRORS | EXEC_DIR_SET_SYSTEMD_EXEC_PID);
|
||||
|
||||
r = 0;
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
/* Put this test here for a lack of better place */
|
||||
assert_cc(EAGAIN == EWOULDBLOCK);
|
||||
|
||||
static int do_spawn(const char *path, char *argv[], int stdout_fd, pid_t *pid) {
|
||||
static int do_spawn(const char *path, char *argv[], int stdout_fd, pid_t *pid, bool set_systemd_exec_pid) {
|
||||
pid_t _pid;
|
||||
int r;
|
||||
|
||||
@ -57,6 +57,12 @@ static int do_spawn(const char *path, char *argv[], int stdout_fd, pid_t *pid) {
|
||||
|
||||
(void) rlimit_nofile_safe();
|
||||
|
||||
if (set_systemd_exec_pid) {
|
||||
r = setenv_systemd_exec_pid(false);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to set $SYSTEMD_EXEC_PID, ignoring: %m");
|
||||
}
|
||||
|
||||
if (!argv) {
|
||||
_argv[0] = (char*) path;
|
||||
_argv[1] = NULL;
|
||||
@ -132,7 +138,7 @@ static int do_execute(
|
||||
return log_error_errno(fd, "Failed to open serialization file: %m");
|
||||
}
|
||||
|
||||
r = do_spawn(t, argv, fd, &pid);
|
||||
r = do_spawn(t, argv, fd, &pid, FLAGS_SET(flags, EXEC_DIR_SET_SYSTEMD_EXEC_PID));
|
||||
if (r <= 0)
|
||||
continue;
|
||||
|
||||
|
@ -15,9 +15,10 @@ enum {
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
EXEC_DIR_NONE = 0, /* No execdir flags */
|
||||
EXEC_DIR_PARALLEL = 1 << 0, /* Execute scripts in parallel, if possible */
|
||||
EXEC_DIR_IGNORE_ERRORS = 1 << 1, /* Ignore non-zero exit status of scripts */
|
||||
EXEC_DIR_NONE = 0, /* No execdir flags */
|
||||
EXEC_DIR_PARALLEL = 1 << 0, /* Execute scripts in parallel, if possible */
|
||||
EXEC_DIR_IGNORE_ERRORS = 1 << 1, /* Ignore non-zero exit status of scripts */
|
||||
EXEC_DIR_SET_SYSTEMD_EXEC_PID = 1 << 2, /* Set $SYSTEMD_EXEC_PID environment variable */
|
||||
} ExecDirFlags;
|
||||
|
||||
typedef enum ExecCommandFlags {
|
||||
|
Loading…
Reference in New Issue
Block a user