X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fdaemon.c;h=c1c6550a94015a367d4f89605b1d97c2ac0e2680;hb=a79f29f20e556514259d8593de779fc1b15c4055;hp=ab579b61914abe2da9063561ab1804457766ebff;hpb=d6056bc7ce15e7b4d1950fda5ad0ee4df7d6a04b;p=sliver-openvswitch.git diff --git a/lib/daemon.c b/lib/daemon.c index ab579b619..c1c6550a9 100644 --- a/lib/daemon.c +++ b/lib/daemon.c @@ -416,7 +416,7 @@ monitor_daemon(pid_t daemon_pid) if (now >= wakeup) { break; } - sleep(wakeup - now); + xsleep(wakeup - now); } } last_restart = time(NULL); @@ -441,6 +441,26 @@ monitor_daemon(pid_t daemon_pid) set_subprogram_name(""); } +/* Returns a readable and writable fd for /dev/null, if successful, otherwise + * a negative errno value. The caller must not close the returned fd (because + * the same fd will be handed out to subsequent callers). */ +static int +get_null_fd(void) +{ + static int null_fd; + + if (!null_fd) { + null_fd = open("/dev/null", O_RDWR); + if (null_fd < 0) { + int error = errno; + VLOG_ERR("could not open /dev/null: %s", ovs_strerror(error)); + null_fd = -error; + } + } + + return null_fd; +} + /* Close standard file descriptors (except any that the client has requested we * leave open by calling daemon_save_fd()). If we're started from e.g. an SSH * session, then this keeps us from holding that session open artificially. */ @@ -717,3 +737,22 @@ check_already_running(void) pidfile, ovs_strerror(-pid)); } } + + +/* stub functions for non-windows platform. */ + +void +service_start(int *argc OVS_UNUSED, char **argv[] OVS_UNUSED) +{ +} + +void +service_stop(void) +{ +} + +bool +should_service_stop(void) +{ + return false; +}