mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
commit
14b6625901
@ -419,13 +419,17 @@ int fork_agent(pid_t *pid, const int except[], unsigned n_except, const char *pa
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!stdout_is_tty)
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
if (!stdout_is_tty && dup2(fd, STDOUT_FILENO) < 0) {
|
||||
log_error_errno(errno, "Failed to dup2 /dev/tty: %m");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!stderr_is_tty)
|
||||
dup2(fd, STDERR_FILENO);
|
||||
if (!stderr_is_tty && dup2(fd, STDERR_FILENO) < 0) {
|
||||
log_error_errno(errno, "Failed to dup2 /dev/tty: %m");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (fd > 2)
|
||||
if (fd > STDERR_FILENO)
|
||||
close(fd);
|
||||
}
|
||||
|
||||
|
@ -110,16 +110,14 @@ int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler) {
|
||||
} else {
|
||||
exists = true;
|
||||
|
||||
/* Path exists, we don't need to watch parent
|
||||
too closely. */
|
||||
/* Path exists, we don't need to watch parent too closely. */
|
||||
if (oldslash) {
|
||||
char *cut2 = oldslash + (oldslash == s->path);
|
||||
char tmp2 = *cut2;
|
||||
*cut2 = '\0';
|
||||
|
||||
inotify_add_watch(s->inotify_fd, s->path, IN_MOVE_SELF);
|
||||
/* Error is ignored, the worst can happen is
|
||||
we get spurious events. */
|
||||
(void) inotify_add_watch(s->inotify_fd, s->path, IN_MOVE_SELF);
|
||||
/* Error is ignored, the worst can happen is we get spurious events. */
|
||||
|
||||
*cut2 = tmp2;
|
||||
}
|
||||
|
@ -832,7 +832,7 @@ static int service_load_pid_file(Service *s, bool may_warn) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int service_search_main_pid(Service *s) {
|
||||
static void service_search_main_pid(Service *s) {
|
||||
pid_t pid = 0;
|
||||
int r;
|
||||
|
||||
@ -841,30 +841,24 @@ static int service_search_main_pid(Service *s) {
|
||||
/* If we know it anyway, don't ever fallback to unreliable
|
||||
* heuristics */
|
||||
if (s->main_pid_known)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
if (!s->guess_main_pid)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
assert(s->main_pid <= 0);
|
||||
|
||||
r = unit_search_main_pid(UNIT(s), &pid);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (unit_search_main_pid(UNIT(s), &pid) < 0)
|
||||
return;
|
||||
|
||||
log_unit_debug(UNIT(s), "Main PID guessed: "PID_FMT, pid);
|
||||
r = service_set_main_pid(s, pid);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (service_set_main_pid(s, pid) < 0)
|
||||
return;
|
||||
|
||||
r = unit_watch_pid(UNIT(s), pid);
|
||||
if (r < 0) {
|
||||
if (r < 0)
|
||||
/* FIXME: we need to do something here */
|
||||
log_unit_warning_errno(UNIT(s), r, "Failed to watch PID "PID_FMT" from: %m", pid);
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void service_set_state(Service *s, ServiceState state) {
|
||||
@ -2729,7 +2723,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
break;
|
||||
}
|
||||
} else
|
||||
(void) service_search_main_pid(s);
|
||||
service_search_main_pid(s);
|
||||
|
||||
service_enter_start_post(s);
|
||||
break;
|
||||
@ -2751,16 +2745,15 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
|
||||
break;
|
||||
}
|
||||
} else
|
||||
(void) service_search_main_pid(s);
|
||||
service_search_main_pid(s);
|
||||
|
||||
service_enter_running(s, SERVICE_SUCCESS);
|
||||
break;
|
||||
|
||||
case SERVICE_RELOAD:
|
||||
if (f == SERVICE_SUCCESS) {
|
||||
service_load_pid_file(s, true);
|
||||
(void) service_search_main_pid(s);
|
||||
}
|
||||
if (f == SERVICE_SUCCESS)
|
||||
if (service_load_pid_file(s, true) < 0)
|
||||
service_search_main_pid(s);
|
||||
|
||||
s->reload_result = f;
|
||||
service_enter_running(s, SERVICE_SUCCESS);
|
||||
|
@ -202,7 +202,7 @@ int main(int argc, char *argv[]) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
cg_get_root_path(&cgroup);
|
||||
(void) cg_get_root_path(&cgroup);
|
||||
|
||||
use_watchdog = !!getenv("WATCHDOG_USEC");
|
||||
|
||||
|
@ -137,7 +137,7 @@ static int curl_glue_socket_callback(CURLM *curl, curl_socket_t s, int action, v
|
||||
if (sd_event_add_io(g->event, &io, fd, events, curl_glue_on_io, g) < 0)
|
||||
return -1;
|
||||
|
||||
sd_event_source_set_description(io, "curl-io");
|
||||
(void) sd_event_source_set_description(io, "curl-io");
|
||||
|
||||
r = hashmap_put(g->ios, FD_TO_PTR(s), io);
|
||||
if (r < 0) {
|
||||
@ -204,7 +204,7 @@ static int curl_glue_timer_callback(CURLM *curl, long timeout_ms, void *userdata
|
||||
if (sd_event_add_time(g->event, &g->timer, clock_boottime_or_monotonic(), usec, 0, curl_glue_on_timer, g) < 0)
|
||||
return -1;
|
||||
|
||||
sd_event_source_set_description(g->timer, "curl-timer");
|
||||
(void) sd_event_source_set_description(g->timer, "curl-timer");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -58,7 +58,7 @@ static gcry_mpi_t mpi_import(const void *buf, size_t buflen) {
|
||||
gcry_mpi_t h;
|
||||
unsigned len;
|
||||
|
||||
gcry_mpi_scan(&h, GCRYMPI_FMT_USG, buf, buflen, NULL);
|
||||
assert_se(gcry_mpi_scan(&h, GCRYMPI_FMT_USG, buf, buflen, NULL) == 0);
|
||||
len = (gcry_mpi_get_nbits(h) + 7) / 8;
|
||||
assert(len <= buflen);
|
||||
assert(gcry_mpi_cmp_ui(h, 0) >= 0);
|
||||
|
@ -579,9 +579,10 @@ static void resolve_free(sd_resolve *resolve) {
|
||||
(void) send(resolve->fds[REQUEST_SEND_FD], &req, req.length, MSG_NOSIGNAL);
|
||||
}
|
||||
|
||||
/* Now terminate them and wait until they are gone. */
|
||||
/* Now terminate them and wait until they are gone.
|
||||
If we get an error than most likely the thread already exited. */
|
||||
for (i = 0; i < resolve->n_valid_workers; i++)
|
||||
pthread_join(resolve->workers[i], NULL);
|
||||
(void) pthread_join(resolve->workers[i], NULL);
|
||||
|
||||
/* Close all communication channels */
|
||||
for (i = 0; i < _FD_MAX; i++)
|
||||
|
@ -148,8 +148,12 @@ int address_pool_acquire(AddressPool *p, unsigned prefixlen, union in_addr_union
|
||||
for (;;) {
|
||||
if (!address_pool_prefix_is_taken(p, &u, prefixlen)) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
int r;
|
||||
|
||||
r = in_addr_to_string(p->family, &u, &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
in_addr_to_string(p->family, &u, &s);
|
||||
log_debug("Found range %s/%u", strna(s), prefixlen);
|
||||
|
||||
*found = u;
|
||||
|
@ -2648,7 +2648,8 @@ static int inner_child(
|
||||
execvpe(arg_parameters[0], arg_parameters, env_use);
|
||||
else {
|
||||
if (!arg_chdir)
|
||||
chdir(home ?: "/root");
|
||||
/* If we cannot change the directory, we'll end up in /, that is expected. */
|
||||
(void) chdir(home ?: "/root");
|
||||
|
||||
execle("/bin/bash", "-bash", NULL, env_use);
|
||||
execle("/bin/sh", "-sh", NULL, env_use);
|
||||
|
@ -424,8 +424,9 @@ static void bus_method_resolve_address_complete(DnsQuery *q) {
|
||||
if (added <= 0) {
|
||||
_cleanup_free_ char *ip = NULL;
|
||||
|
||||
in_addr_to_string(q->request_family, &q->request_address, &ip);
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR, "Address '%s' does not have any RR of requested type", strna(ip));
|
||||
(void) in_addr_to_string(q->request_family, &q->request_address, &ip);
|
||||
r = sd_bus_reply_method_errorf(q->request, BUS_ERROR_NO_SUCH_RR,
|
||||
"Address '%s' does not have any RR of requested type", strnull(ip));
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
@ -262,7 +262,7 @@ static void dns_transaction_tentative(DnsTransaction *t, DnsPacket *p) {
|
||||
if (manager_our_packet(t->scope->manager, p) != 0)
|
||||
return;
|
||||
|
||||
in_addr_to_string(p->family, &p->sender, &pretty);
|
||||
(void) in_addr_to_string(p->family, &p->sender, &pretty);
|
||||
|
||||
log_debug("Transaction %" PRIu16 " for <%s> on scope %s on %s/%s got tentative packet from %s.",
|
||||
t->id,
|
||||
@ -270,7 +270,7 @@ static void dns_transaction_tentative(DnsTransaction *t, DnsPacket *p) {
|
||||
dns_protocol_to_string(t->scope->protocol),
|
||||
t->scope->link ? t->scope->link->name : "*",
|
||||
af_to_name_short(t->scope->family),
|
||||
pretty);
|
||||
strnull(pretty));
|
||||
|
||||
/* RFC 4795, Section 4.1 says that the peer with the
|
||||
* lexicographically smaller IP address loses */
|
||||
|
@ -40,7 +40,7 @@ static void sig_handler(int signum) {
|
||||
static void print_device(struct udev_device *device, const char *source, int prop) {
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
assert_se(clock_gettime(CLOCK_MONOTONIC, &ts) == 0);
|
||||
printf("%-6s[%"PRI_TIME".%06ld] %-8s %s (%s)\n",
|
||||
source,
|
||||
ts.tv_sec, ts.tv_nsec/1000,
|
||||
|
@ -400,10 +400,11 @@ static void worker_spawn(Manager *manager, struct event *event) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* request TERM signal if parent exits */
|
||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||
/* Request TERM signal if parent exits.
|
||||
Ignore error, not much we can do in that case. */
|
||||
(void) prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||
|
||||
/* reset OOM score, we only protect the main daemon */
|
||||
/* Reset OOM score, we only protect the main daemon. */
|
||||
write_string_file("/proc/self/oom_score_adj", "0", 0);
|
||||
|
||||
for (;;) {
|
||||
|
Loading…
Reference in New Issue
Block a user