activate.c revision 7b7afdfc072b14a4fa4dc195f50becaa7cecc5e8
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek This file is part of systemd.
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek Copyright 2013 Zbigniew Jędrzejewski-Szmek
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek (at your option) any later version.
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic bool arg_accept = false;
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic bool arg_datagram = false;
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic const char *arg_fdname = NULL;
d6170d27b26eeeace966bb9720d66fcac2a6ef1bZbigniew Jędrzejewski-Szmekstatic int add_epoll(int epoll_fd, int fd) {
char **address;
int n, fd, r;
int count = 0;
n = sd_listen_fds(true);
count ++;
if (arg_listen) {
log_close();
if (arg_datagram)
if (fd < 0) {
log_open();
count ++;
if (arg_listen)
log_open();
if (*epoll_fd < 0)
return count;
if (!envp)
return log_oom();
_cleanup_free_ char *p;
return log_oom();
n_env ++;
n_env ++;
return log_oom();
if (arg_fdname) {
return log_oom();
free(e);
return log_oom();
free(e);
if (!tmp)
return log_oom();
if (!tmp)
return log_oom();
if (child_pid < 0)
if (child_pid == 0) {
(void) reset_all_signal_handlers();
(void) reset_signal_mask();
if (fd2 < 0) {
return fd2;
static int install_chld_handler(void) {
static void help(void) {
help();
case ARG_VERSION:
return version();
return log_oom();
arg_datagram = true;
arg_accept = true;
return log_oom();
case ARG_FDNAME:
return -EINVAL;
return -EINVAL;
return -EINVAL;
return -EINVAL;
log_open();
r = install_chld_handler();
return EXIT_FAILURE;
return EXIT_FAILURE;
return EXIT_FAILURE;
return EXIT_FAILURE;
if (arg_accept) {
return EXIT_FAILURE;
return EXIT_SUCCESS;