Skip to content

Commit

Permalink
debug pidfile
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <[email protected]>
  • Loading branch information
zhangzujian committed Nov 14, 2023
1 parent 6a29598 commit 4aaf4fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/daemon-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <config.h>
#include "backtrace.h"
#include "daemon.h"
#include "daemon-private.h"
// #include "daemon-private.h"
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
Expand All @@ -29,6 +29,7 @@
#include <sys/wait.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#if HAVE_LIBCAPNG
#include <cap-ng.h>
#endif
Expand Down Expand Up @@ -490,6 +491,9 @@ daemonize_start(bool access_datapath)

if (pidfile) {
make_pidfile();
} else {
pid_t tid = gettid();
VLOG_WARN("pidfile %x in thread %u is NULL", &pidfile, tid);
}

/* Make sure that the unixctl commands for vlog get registered in a
Expand Down
6 changes: 6 additions & 0 deletions lib/daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include "util.h"
#include "ovs-thread.h"
#include "openvswitch/vlog.h"
Expand Down Expand Up @@ -61,9 +62,14 @@ daemonize(void)
void
set_pidfile(const char *name)
{
printf("set_pidfile(%s)\n", name);
VLOG_WARN("set_pidfile(%s)", name);
assert_single_threaded();
free(pidfile);
pidfile = make_pidfile_name(name);
pid_t tid = gettid();
VLOG_WARN("pidfile %x in thread %u is set to %s", &pidfile, tid, pidfile);
printf("pidfile %x in thread %u is set to %s\n", &pidfile, tid, pidfile);
}

/* Disables self confinement. */
Expand Down

0 comments on commit 4aaf4fd

Please sign in to comment.