X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ltt%2Fbranches%2Fpoly%2Flttd%2Flttd.c;h=9a6b3d68b732bc86267edd9bcaa6c4c0b05c8361;hb=13ac5fb1d50e878d692de60e76b3797bec42bd57;hp=01f1dd6dc262a7f5e9bdb6a6200ffefa0699a846;hpb=b1e3e7c791a7927d978d14b0e20ae478a13c8610;p=ltt-control.git diff --git a/ltt/branches/poly/lttd/lttd.c b/ltt/branches/poly/lttd/lttd.c index 01f1dd6..9a6b3d6 100644 --- a/ltt/branches/poly/lttd/lttd.c +++ b/ltt/branches/poly/lttd/lttd.c @@ -35,7 +35,7 @@ /* Get the next sub buffer that can be read. */ #define RELAYFS_GET_SUBBUF _IOR(0xF4, 0x00,__u32) /* Release the oldest reserved (by "get") sub buffer. */ -#define RELAYFS_PUT_SUBBUF _IO(0xF4, 0x01) +#define RELAYFS_PUT_SUBBUF _IOW(0xF4, 0x01,__u32) /* returns the number of sub buffers in the per cpu channel. */ #define RELAYFS_GET_N_SUBBUFS _IOR(0xF4, 0x02,__u32) /* returns the size of the sub buffers. */ @@ -67,7 +67,6 @@ static char *trace_name = NULL; static char *channel_name = NULL; static int daemon_mode = 0; static int append_mode = 0; -static int sig_parent = 0; volatile static int quit_program = 0; /* For signal handler */ /* Args : @@ -76,7 +75,7 @@ volatile static int quit_program = 0; /* For signal handler */ * -c directory Root directory of the relayfs trace channels. * -d Run in background (daemon). * -a Trace append mode. - * -s Send SIGIO to parent when ready for IO. + * -s Send SIGUSR1 to parent when ready for IO. */ void show_arguments(void) { @@ -87,7 +86,6 @@ void show_arguments(void) printf("-c directory Root directory of the relayfs trace channels.\n"); printf("-d Run in background (daemon).\n"); printf("-a Append to an possibly existing trace.\n"); - printf("-s Send SIGIO to parent when ready for IO.\n"); printf("\n"); } @@ -133,9 +131,6 @@ int parse_arguments(int argc, char **argv) case 'a': append_mode = 1; break; - case 's': - sig_parent = 1; - break; default: printf("Invalid argument '%s'.\n", argv[argn]); printf("\n"); @@ -410,9 +405,6 @@ int read_channels(struct channel_trace_fd *fd_pairs) pollfd[i].events = POLLIN|POLLPRI; } - /* Signal the parent that ready for IO */ - if(sig_parent) kill(getppid(), SIGIO); - while(1) { high_prio = 0; num_hup = 0; @@ -513,7 +505,6 @@ void close_channel_trace_pairs(struct channel_trace_fd *fd_pairs) int main(int argc, char ** argv) { int ret; - pid_t pid; struct channel_trace_fd fd_pairs = { NULL, 0 }; struct sigaction act; @@ -526,18 +517,13 @@ int main(int argc, char ** argv) show_info(); if(daemon_mode) { - pid = fork(); - - if(pid > 0) { - /* parent */ - return 0; - } else if(pid < 0) { - /* error */ - printf("An error occured while forking.\n"); - return -1; - } - /* else, we are the child, continue... */ - } + ret = daemon(0, 0); + + if(ret == -1) { + perror("An error occured while daemonizing."); + exit(-1); + } + } /* Connect the signal handlers */ act.sa_handler = handler;