X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Fovsdb-client.c;h=02946df6d02a58104813c046b52da2fd88e598dc;hb=77909859b05f0d2466069883306e8d75d280bbe7;hp=fa17bd92ed731223c82bdfade9291987d99abf48;hpb=9467fe624698a9b72f81bb1ddfce33a5fc85281c;p=openvswitch diff --git a/ovsdb/ovsdb-client.c b/ovsdb/ovsdb-client.c index fa17bd92..02946df6 100644 --- a/ovsdb/ovsdb-client.c +++ b/ovsdb/ovsdb-client.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Nicira Networks. + * Copyright (c) 2009, 2010 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ #include +#include #include #include #include @@ -66,6 +67,7 @@ static void parse_options(int argc, char *argv[]); int main(int argc, char *argv[]) { + proctitle_init(argc, argv); set_program_name(argv[0]); time_init(); vlog_init(); @@ -841,7 +843,14 @@ do_monitor(int argc, char *argv[]) && json_equal(msg->id, request_id)) { monitor_print(msg->result, table, &columns, true); fflush(stdout); - daemonize(); + if (get_detach()) { + /* daemonize() closes the standard file descriptors. We output + * to stdout, so we need to save and restore STDOUT_FILENO. */ + int fd = dup(STDOUT_FILENO); + daemonize(); + dup2(fd, STDOUT_FILENO); + close(fd); + } } else if (msg->type == JSONRPC_NOTIFY && !strcmp(msg->method, "update")) { struct json *params = msg->params;