X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=ust%2Fust.c;h=766a2fa2c01e20d20c4b3acd8c921a1aa135db0e;hb=1f8b0dffac11b11fa7b582b6274c6b4cadf57bb3;hp=1fb7d098c521da7d085d857e598deefeccacd802;hpb=fbd8191b00521bbe7e52a6d1ff4bb814708f06ba;p=lttng-ust.git diff --git a/ust/ust.c b/ust/ust.c index 1fb7d098..766a2fa2 100644 --- a/ust/ust.c +++ b/ust/ust.c @@ -3,19 +3,8 @@ #include #include #include -#include -#include -#include -#include -#include -#define UNIX_PATH_MAX 108 -#define SOCK_DIR "/tmp/socks" -#define UST_SIGNAL SIGIO - -struct ust_msg { - char *raw; -}; +#include "ustcomm.h" void parse_opts(int argc, char **argv) { @@ -56,73 +45,13 @@ void parse_opts(int argc, char **argv) } -void signal_process(pid_t pid) -{ - int result; - - result = kill(pid, UST_SIGNAL); - if(result == -1) { - perror("kill"); - return; - } - - sleep(1); -} - -int send_message(pid_t pid, const char *msg) -{ - int fd; - int result; - struct sockaddr_un addr; - - result = fd = socket(PF_UNIX, SOCK_DGRAM, 0); - if(result == -1) { - perror("socket"); - return 1; - } - - addr.sun_family = AF_UNIX; - - result = snprintf(addr.sun_path, UNIX_PATH_MAX, "%s/%d", SOCK_DIR, pid); - if(result >= UNIX_PATH_MAX) { - fprintf(stderr, "string overflow allocating socket name"); - return 1; - } - - char buf[] = "print_markers\n"; - - signal_process(pid); - - result = sendto(fd, buf, sizeof(buf), 0, (struct sockaddr *)&addr, sizeof(addr)); - if(result == -1) { - perror("sendto"); - return 1; - } - -// result = fd = open(sockfile, O_RDWR); -// if(result == -1 && errno == ENXIO) { -// fprintf(stderr, "signalling process\n"); -// -// result = fd = open(sockfile, O_RDWR); -// if(result == -1) { -// perror("open"); -// return 1; -// } -// } -// else if(result == -1) { -// perror("open"); -// return 1; -// } - -} - int main(int argc, char *argv[]) { pid_t pid = atoi(argv[1]); char *msg = argv[2]; - send_message(pid, msg); + send_message(pid, msg, NULL); return 0; }