2 * ust-basic-tracing.c - Basic single-session, single-channel, single-process UST tracing
4 * Copyright (C) 2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; only version 2 of the License.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along with
17 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18 * Place - Suite 330, Boston, MA 02111-1307, USA.
21 #define _LARGEFILE64_SOURCE
29 #include <sys/types.h>
34 #include <urcu/futex.h>
35 #include <urcu/uatomic.h>
37 #include <sys/socket.h>
39 #include "lttng-ust-comm.h"
40 #include "../../libringbuffer/backend.h"
41 #include "../../libringbuffer/frontend.h"
43 #define MAX_NR_STREAMS 64
44 #define MAX_NR_EVENTS 128
50 uint64_t memory_map_size
;
53 static int session_handle
;
54 static struct object_data metadata_stream_data
;
55 static struct object_data metadata_data
;
56 static struct object_data channel_data
;
57 static struct object_data stream_data
[MAX_NR_STREAMS
];
58 static int event_handle
[MAX_NR_EVENTS
];
59 static int context_handle
;
61 static int apps_socket
= -1;
62 static char apps_sock_path
[PATH_MAX
];
63 static char local_apps_wait_shm_path
[PATH_MAX
];
65 static volatile int quit_program
;
67 static void handle_signals(int signo
)
72 static int send_app_msg(int sock
, struct lttcomm_ust_msg
*lum
)
76 len
= lttcomm_send_unix_sock(sock
, lum
, sizeof(*lum
));
79 printf("message successfully sent\n");
82 if (errno
== ECONNRESET
) {
83 printf("remote end closed connection\n");
88 printf("incorrect message size: %zd\n", len
);
94 static int recv_app_reply(int sock
, struct lttcomm_ust_reply
*lur
,
95 uint32_t expected_handle
, uint32_t expected_cmd
)
99 memset(lur
, 0, sizeof(*lur
));
100 len
= lttcomm_recv_unix_sock(sock
, lur
, sizeof(*lur
));
102 case 0: /* orderly shutdown */
103 printf("Application has performed an orderly shutdown\n");
106 printf("result message received\n");
107 if (lur
->handle
!= expected_handle
) {
108 printf("Unexpected result message handle\n");
112 if (lur
->cmd
!= expected_cmd
) {
113 printf("Unexpected result message command\n");
116 if (lur
->ret_code
!= LTTCOMM_OK
) {
117 printf("remote operation failed with code %d.\n",
119 return lur
->ret_code
;
123 if (errno
== ECONNRESET
) {
124 printf("remote end closed connection\n");
129 printf("incorrect message size: %zd\n", len
);
130 return len
> 0 ? -1 : len
;
134 static int send_app_cmd(int sock
,
135 struct lttcomm_ust_msg
*lum
,
136 struct lttcomm_ust_reply
*lur
)
140 ret
= send_app_msg(sock
, lum
);
143 ret
= recv_app_reply(sock
, lur
, lum
->handle
, lum
->cmd
);
151 * Receives a single fd from socket.
153 * Returns the size of received data
155 static int lttcomm_recv_fd(int sock
)
160 struct cmsghdr
*cmsg
;
161 char recv_fd
[CMSG_SPACE(sizeof(int))];
162 struct msghdr msg
= { 0 };
169 /* Prepare to receive the structures */
170 iov
[0].iov_base
= &data_fd
;
171 iov
[0].iov_len
= sizeof(data_fd
);
174 msg
.msg_control
= recv_fd
;
175 msg
.msg_controllen
= sizeof(recv_fd
);
177 printf("Waiting to receive fd\n");
178 if ((ret
= recvmsg(sock
, &msg
, 0)) < 0) {
182 if (ret
!= sizeof(data_fd
)) {
183 printf("Received %d bytes, expected %ld", ret
, sizeof(data_fd
));
186 cmsg
= CMSG_FIRSTHDR(&msg
);
188 printf("Invalid control message header\n");
192 if (cmsg
->cmsg_level
!= SOL_SOCKET
|| cmsg
->cmsg_type
!= SCM_RIGHTS
) {
193 printf("Didn't received any fd\n");
198 for (i
= 0; i
< sizeof(int); i
++)
199 tmp
.vc
[i
] = CMSG_DATA(cmsg
)[i
];
201 printf("received fd %d\n", ret
);
208 int open_streams(int sock
, int channel_handle
, struct object_data
*stream_datas
,
214 struct lttcomm_ust_msg lum
;
215 struct lttcomm_ust_reply lur
;
217 memset(&lum
, 0, sizeof(lum
));
218 lum
.handle
= channel_handle
;
219 lum
.cmd
= LTTNG_UST_STREAM
;
220 ret
= send_app_cmd(sock
, &lum
, &lur
);
222 assert(k
< nr_check
);
223 stream_datas
[k
].handle
= lur
.ret_val
;
224 printf("received stream handle %u\n",
225 stream_datas
[k
].handle
);
226 if (lur
.ret_code
== LTTCOMM_OK
) {
229 stream_datas
[k
].memory_map_size
= lur
.u
.stream
.memory_map_size
;
231 len
= lttcomm_recv_fd(sock
);
234 stream_datas
[k
].shm_fd
= len
;
236 len
= lttcomm_recv_fd(sock
);
239 stream_datas
[k
].wait_fd
= len
;
252 int close_streams(int sock
, struct object_data
*stream_datas
, int nr_check
)
256 for (k
= 0; k
< nr_check
; k
++) {
257 struct lttcomm_ust_msg lum
;
258 struct lttcomm_ust_reply lur
;
260 if (!stream_datas
[k
].handle
)
262 memset(&lum
, 0, sizeof(lum
));
263 lum
.handle
= stream_datas
[k
].handle
;
264 lum
.cmd
= LTTNG_UST_RELEASE
;
265 ret
= send_app_cmd(sock
, &lum
, &lur
);
267 printf("Error closing stream\n");
270 if (stream_datas
[k
].shm_fd
>= 0) {
271 ret
= close(stream_datas
[k
].shm_fd
);
273 printf("Error closing stream shm_fd\n");
277 if (stream_datas
[k
].wait_fd
>= 0) {
278 ret
= close(stream_datas
[k
].wait_fd
);
280 printf("Error closing stream wait_fd\n");
289 struct shm_handle
*map_channel(struct object_data
*chan_data
,
290 struct object_data
*stream_datas
, int nr_check
)
292 struct shm_handle
*handle
;
293 struct channel
*chan
;
296 /* map metadata channel */
297 handle
= channel_handle_create(chan_data
->shm_fd
,
299 chan_data
->memory_map_size
);
301 printf("create handle error\n");
304 chan_data
->shm_fd
= -1;
305 chan_data
->wait_fd
= -1;
306 chan
= shmp(handle
, handle
->chan
);
308 for (k
= 0; k
< nr_check
; k
++) {
309 struct object_data
*stream_data
= &stream_datas
[k
];
311 if (!stream_data
->handle
)
314 ret
= channel_handle_add_stream(handle
,
316 stream_data
->wait_fd
,
317 stream_data
->memory_map_size
);
319 printf("add stream error\n");
322 stream_data
->shm_fd
= -1;
323 stream_data
->wait_fd
= -1;
328 channel_destroy(chan
, handle
, 1);
333 void unmap_channel(struct shm_handle
*handle
)
335 struct channel
*chan
;
337 chan
= shmp(handle
, handle
->chan
);
339 channel_destroy(chan
, handle
, 1);
343 int consume_stream(struct shm_handle
*handle
, int cpu
, char *outfile
)
345 struct channel
*chan
;
346 struct lib_ring_buffer
*buf
;
349 uint64_t memory_map_size
;
351 chan
= shmp(handle
, handle
->chan
);
354 buf
= channel_get_ring_buffer(&chan
->backend
.config
,
355 chan
, cpu
, handle
, &shm_fd
, &wait_fd
, &memory_map_size
);
358 ret
= lib_ring_buffer_open_read(buf
, handle
, 1);
364 outfd
= open(outfile
, O_WRONLY
| O_CREAT
| O_LARGEFILE
| O_TRUNC
,
365 S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
);
367 perror("open output");
371 printf("Waiting for buffer data for %s\n", outfile
);
373 unsigned long read_size
;
374 unsigned long copy_size
;
377 ret
= lib_ring_buffer_get_next_subbuf(buf
, handle
);
378 printf("get next ret %d\n", ret
);
381 if (ret
== -EAGAIN
) {
386 printf("Error %d in lib_ring_buffer_get_next_subbuf\n", ret
);
389 read_size
= lib_ring_buffer_get_read_data_size(
390 &chan
->backend
.config
, buf
, handle
);
391 read_size
= PAGE_ALIGN(read_size
);
392 ptr
= lib_ring_buffer_read_offset_address(
393 &buf
->backend
, 0, handle
);
394 printf("WRITE: copy %lu bytes\n", read_size
);
395 copy_size
= write(outfd
, ptr
, read_size
);
396 if (copy_size
< read_size
) {
397 printf("write issue: copied %zd, expected %lu\n", copy_size
, read_size
);
399 lib_ring_buffer_put_next_subbuf(buf
, handle
);
409 lib_ring_buffer_release_read(buf
, handle
, 1);
414 int consume_buffers(const char *outputpath
)
418 char pathname
[PATH_MAX
];
419 struct shm_handle
*handle
;
421 snprintf(pathname
, PATH_MAX
- 1, "%s", outputpath
);
422 old_umask
= umask(0);
423 ret
= mkdir(pathname
, S_IRWXU
| S_IRWXG
);
424 if (ret
&& errno
!= EEXIST
) {
432 handle
= map_channel(&metadata_data
,
433 &metadata_stream_data
, 1);
436 snprintf(pathname
, PATH_MAX
- 1,
437 "%s/metadata", outputpath
);
438 ret
= consume_stream(handle
, -1, pathname
);
439 if (ret
&& ret
!= -ENOENT
) {
440 printf("Error in consume_stream\n");
443 unmap_channel(handle
);
445 /* copy binary data */
446 handle
= map_channel(&channel_data
,
447 stream_data
, MAX_NR_STREAMS
);
450 for (k
= 0; k
< MAX_NR_STREAMS
; k
++) {
451 snprintf(pathname
, PATH_MAX
- 1,
452 "%s/data_%u", outputpath
, k
);
453 ret
= consume_stream(handle
, k
, pathname
);
454 if (ret
&& ret
!= -ENOENT
) {
455 printf("Error in consume_stream\n");
459 unmap_channel(handle
);
464 int send_app_msgs(int sock
, const char *outputpath
,
465 unsigned int nr_events
, const char **event_names
)
467 struct lttcomm_ust_msg lum
;
468 struct lttcomm_ust_reply lur
;
472 memset(&lum
, 0, sizeof(lum
));
473 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
474 lum
.cmd
= LTTNG_UST_SESSION
;
475 ret
= send_app_cmd(sock
, &lum
, &lur
);
478 session_handle
= lur
.ret_val
;
479 printf("received session handle %u\n", session_handle
);
481 /* Create metadata channel */
482 memset(&lum
, 0, sizeof(lum
));
483 lum
.handle
= session_handle
;
484 lum
.cmd
= LTTNG_UST_METADATA
;
485 lum
.u
.channel
.overwrite
= 0;
486 lum
.u
.channel
.subbuf_size
= 32768;
487 lum
.u
.channel
.num_subbuf
= 4;
488 lum
.u
.channel
.switch_timer_interval
= 0;
489 lum
.u
.channel
.read_timer_interval
= 0;
490 lum
.u
.channel
.output
= LTTNG_UST_MMAP
;
491 ret
= send_app_cmd(sock
, &lum
, &lur
);
494 metadata_data
.handle
= lur
.ret_val
;
495 printf("received metadata handle %u\n", metadata_data
.handle
);
496 if (lur
.ret_code
== LTTCOMM_OK
) {
499 metadata_data
.memory_map_size
= lur
.u
.channel
.memory_map_size
;
501 len
= lttcomm_recv_fd(sock
);
504 metadata_data
.shm_fd
= len
;
506 len
= lttcomm_recv_fd(sock
);
509 metadata_data
.wait_fd
= len
;
512 ret
= open_streams(sock
, metadata_data
.handle
,
513 &metadata_stream_data
, 1);
515 printf("Error in open_streams\n");
519 /* Create data channel */
520 memset(&lum
, 0, sizeof(lum
));
521 lum
.handle
= session_handle
;
522 lum
.cmd
= LTTNG_UST_CHANNEL
;
523 //lum.u.channel.overwrite = 0;
524 lum
.u
.channel
.overwrite
= 1;
525 lum
.u
.channel
.subbuf_size
= 32768;
526 lum
.u
.channel
.num_subbuf
= 8;
527 //lum.u.channel.num_subbuf = 4;
528 //lum.u.channel.num_subbuf = 2;
529 lum
.u
.channel
.switch_timer_interval
= 0;
530 lum
.u
.channel
.read_timer_interval
= 0;
531 lum
.u
.channel
.output
= LTTNG_UST_MMAP
;
532 ret
= send_app_cmd(sock
, &lum
, &lur
);
535 channel_data
.handle
= lur
.ret_val
;
536 printf("received channel handle %u\n", channel_data
.handle
);
537 if (lur
.ret_code
== LTTCOMM_OK
) {
540 channel_data
.memory_map_size
= lur
.u
.channel
.memory_map_size
;
542 len
= lttcomm_recv_fd(sock
);
545 channel_data
.shm_fd
= len
;
547 len
= lttcomm_recv_fd(sock
);
550 channel_data
.wait_fd
= len
;
554 for (k
= 0; k
< nr_events
; k
++) {
555 memset(&lum
, 0, sizeof(lum
));
556 lum
.handle
= channel_data
.handle
;
557 lum
.cmd
= LTTNG_UST_EVENT
;
558 strncpy(lum
.u
.event
.name
, event_names
[k
],
559 LTTNG_UST_SYM_NAME_LEN
);
560 lum
.u
.event
.instrumentation
= LTTNG_UST_TRACEPOINT
;
561 ret
= send_app_cmd(sock
, &lum
, &lur
);
564 event_handle
[k
] = lur
.ret_val
;
565 printf("received event handle %u\n", event_handle
[k
]);
568 /* Attach vtid context */
569 memset(&lum
, 0, sizeof(lum
));
570 lum
.handle
= channel_data
.handle
;
571 lum
.cmd
= LTTNG_UST_CONTEXT
;
572 lum
.u
.context
.ctx
= LTTNG_UST_CONTEXT_VTID
;
573 //lum.u.context.ctx = LTTNG_UST_CONTEXT_PTHREAD_ID;
574 //lum.u.context.ctx = LTTNG_UST_CONTEXT_VPID;
575 //lum.u.context.ctx = LTTNG_UST_CONTEXT_PROCNAME;
576 ret
= send_app_cmd(sock
, &lum
, &lur
);
579 context_handle
= lur
.ret_val
;
580 printf("received context handle %u\n", context_handle
);
582 /* Get references to channel streams */
583 ret
= open_streams(sock
, channel_data
.handle
,
584 stream_data
, MAX_NR_STREAMS
);
586 printf("Error in open_streams\n");
590 memset(&lum
, 0, sizeof(lum
));
591 lum
.handle
= session_handle
;
592 lum
.cmd
= LTTNG_UST_SESSION_START
;
593 ret
= send_app_cmd(sock
, &lum
, &lur
);
596 printf("Session handle %u started.\n", session_handle
);
598 /* Tell application registration is done */
599 memset(&lum
, 0, sizeof(lum
));
600 lum
.handle
= LTTNG_UST_ROOT_HANDLE
;
601 lum
.cmd
= LTTNG_UST_REGISTER_DONE
;
602 ret
= send_app_cmd(sock
, &lum
, &lur
);
605 printf("Registration done acknowledged.\n");
609 ret
= consume_buffers(outputpath
);
611 printf("Error in consume_buffers\n");
615 /* Release data channel */
616 /* Release streams */
617 ret
= close_streams(sock
, stream_data
,
622 /* Release context */
623 memset(&lum
, 0, sizeof(lum
));
624 lum
.handle
= context_handle
;
625 lum
.cmd
= LTTNG_UST_RELEASE
;
626 ret
= send_app_cmd(sock
, &lum
, &lur
);
631 for (k
= 0; k
< nr_events
; k
++) {
632 memset(&lum
, 0, sizeof(lum
));
633 lum
.handle
= event_handle
[k
];
634 lum
.cmd
= LTTNG_UST_RELEASE
;
635 ret
= send_app_cmd(sock
, &lum
, &lur
);
639 memset(&lum
, 0, sizeof(lum
));
640 lum
.handle
= channel_data
.handle
;
641 lum
.cmd
= LTTNG_UST_RELEASE
;
642 ret
= send_app_cmd(sock
, &lum
, &lur
);
645 if (channel_data
.shm_fd
>= 0) {
646 ret
= close(channel_data
.shm_fd
);
650 if (channel_data
.wait_fd
>= 0) {
651 ret
= close(channel_data
.wait_fd
);
656 /* Release metadata channel */
657 ret
= close_streams(sock
, &metadata_stream_data
, 1);
661 memset(&lum
, 0, sizeof(lum
));
662 lum
.handle
= metadata_data
.handle
;
663 lum
.cmd
= LTTNG_UST_RELEASE
;
664 ret
= send_app_cmd(sock
, &lum
, &lur
);
667 if (metadata_data
.shm_fd
>= 0) {
668 ret
= close(metadata_data
.shm_fd
);
672 if (metadata_data
.wait_fd
>= 0) {
673 ret
= close(metadata_data
.wait_fd
);
678 /* Release session */
679 memset(&lum
, 0, sizeof(lum
));
680 lum
.handle
= session_handle
;
681 lum
.cmd
= LTTNG_UST_RELEASE
;
682 ret
= send_app_cmd(sock
, &lum
, &lur
);
690 * Using fork to set umask in the child process (not multi-thread safe). We
691 * deal with the shm_open vs ftruncate race (happening when the sessiond owns
692 * the shm and does not let everybody modify it, to ensure safety against
693 * shm_unlink) by simply letting the mmap fail and retrying after a few
694 * seconds. For global shm, everybody has rw access to it until the sessiond
697 static int get_wait_shm(char *shm_path
, size_t mmap_size
, int global
)
699 int wait_shm_fd
, ret
;
702 /* Default permissions */
703 mode
= S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
;
705 /* Change owner of the shm path */
707 ret
= chown(shm_path
, 0, 0);
709 if (errno
!= ENOENT
) {
710 perror("chown wait shm");
716 * If global session daemon, any application can register so the shm
717 * needs to be set in read-only mode for others.
721 ret
= chown(shm_path
, getuid(), getgid());
723 if (errno
!= ENOENT
) {
724 perror("chown wait shm");
731 * Set permissions to the shm even if we did not create the shm.
733 ret
= chmod(shm_path
, mode
);
735 if (errno
!= ENOENT
) {
736 perror("chmod wait shm");
742 * We're alone in a child process, so we can modify the process-wide
748 * Try creating shm (or get rw access). We don't do an exclusive open,
749 * because we allow other processes to create+ftruncate it concurrently.
751 wait_shm_fd
= shm_open(shm_path
, O_RDWR
| O_CREAT
, mode
);
752 if (wait_shm_fd
< 0) {
753 perror("shm_open wait shm");
757 ret
= ftruncate(wait_shm_fd
, mmap_size
);
759 perror("ftruncate wait shm");
763 ret
= fchmod(wait_shm_fd
, mode
);
769 printf("Got the wait shm fd %d\n", wait_shm_fd
);
774 printf("Failing to get the wait shm fd\n");
779 int update_futex(int fd
, int active
)
781 size_t mmap_size
= sysconf(_SC_PAGE_SIZE
);
785 wait_shm_mmap
= mmap(NULL
, mmap_size
, PROT_READ
| PROT_WRITE
,
787 if (wait_shm_mmap
== MAP_FAILED
) {
793 uatomic_set((int32_t *) wait_shm_mmap
, 1);
794 futex_async((int32_t *) wait_shm_mmap
, FUTEX_WAKE
,
795 INT_MAX
, NULL
, NULL
, 0);
797 uatomic_set((int32_t *) wait_shm_mmap
, 0);
799 ret
= munmap(wait_shm_mmap
, mmap_size
);
801 perror("Error unmapping wait shm");
810 * Set open files limit to unlimited. This daemon can open a large number of
811 * file descriptors in order to consumer multiple kernel traces.
813 static void set_ulimit(void)
819 * If not root, we cannot increase our max open files. But our
820 * scope is then limited to processes from a single user.
824 /* The kernel does not allowed an infinite limit for open files */
825 lim
.rlim_cur
= 65535;
826 lim
.rlim_max
= 65535;
828 ret
= setrlimit(RLIMIT_NOFILE
, &lim
);
830 perror("failed to set open files limit");
836 * ./ust-basic-tracing outputpath event_name1 event_name2 ....
838 int main(int argc
, const char **argv
)
840 const char *home_dir
;
841 int ret
, wait_shm_fd
;
842 struct sigaction act
;
843 mode_t old_umask
= 0;
844 const char *outputpath
;
845 const char **event_names
;
846 unsigned int nr_events
;
850 printf("%s outputpath event_name1 event_name2 ...\n",
854 outputpath
= argv
[1];
855 event_names
= &argv
[2];
856 nr_events
= argc
- 2;
861 memset(&act
, 0, sizeof(act
));
862 ret
= sigemptyset(&act
.sa_mask
);
864 perror("sigemptyset");
868 act
.sa_handler
= SIG_IGN
;
869 ret
= sigaction(SIGPIPE
, &act
, NULL
);
876 act
.sa_handler
= handle_signals
;
877 ret
= sigaction(SIGTERM
, &act
, NULL
);
883 ret
= sigaction(SIGINT
, &act
, NULL
);
889 if (geteuid() == 0) {
890 ret
= mkdir(LTTNG_RUNDIR
, S_IRWXU
| S_IRWXG
| S_IROTH
| S_IXOTH
);
891 if (ret
&& errno
!= EEXIST
) {
895 wait_shm_fd
= get_wait_shm(DEFAULT_GLOBAL_APPS_WAIT_SHM_PATH
,
896 sysconf(_SC_PAGE_SIZE
), 1);
897 if (wait_shm_fd
< 0) {
898 perror("global wait shm error");
901 strcpy(apps_sock_path
, DEFAULT_GLOBAL_APPS_UNIX_SOCK
);
902 old_umask
= umask(0);
904 snprintf(local_apps_wait_shm_path
, PATH_MAX
,
905 DEFAULT_HOME_APPS_WAIT_SHM_PATH
, getuid());
906 wait_shm_fd
= get_wait_shm(local_apps_wait_shm_path
,
907 sysconf(_SC_PAGE_SIZE
), 0);
908 if (wait_shm_fd
< 0) {
909 perror("local wait shm error");
912 home_dir
= (const char *) getenv("HOME");
914 perror("getenv error");
917 snprintf(apps_sock_path
, PATH_MAX
,
918 DEFAULT_HOME_APPS_UNIX_SOCK
, home_dir
);
921 ret
= lttcomm_create_unix_sock(apps_sock_path
);
923 perror("create error");
929 /* File permission MUST be 666 */
930 ret
= chmod(apps_sock_path
,
931 S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
| S_IROTH
| S_IWOTH
);
933 printf("Set file permissions failed: %s\n", apps_sock_path
);
939 ret
= lttcomm_listen_unix_sock(apps_socket
);
941 perror("listen error");
945 /* wake up futexes */
946 ret
= update_futex(wait_shm_fd
, 1);
948 fprintf(stderr
, "Error wakeup futex\n");
962 char name
[16]; /* Process name */
969 printf("Accepting application registration\n");
970 sock
= lttcomm_accept_unix_sock(apps_socket
);
972 perror("accept error");
977 * Basic recv here to handle the very simple data
978 * that the libust send to register (reg_msg).
980 len
= lttcomm_recv_unix_sock(sock
, ®_msg
, sizeof(reg_msg
));
981 if (len
< 0 || len
!= sizeof(reg_msg
)) {
982 perror("lttcomm_recv_unix_sock");
985 memcpy(bufname
, reg_msg
.name
, 16);
987 printf("Application %s pid %u ppid %u uid %u gid %u has registered (version : %u.%u)\n",
988 bufname
, reg_msg
.pid
, reg_msg
.ppid
, reg_msg
.uid
,
989 reg_msg
.gid
, reg_msg
.major
, reg_msg
.minor
);
990 ret
= send_app_msgs(sock
, outputpath
, nr_events
, event_names
);
992 printf("Error in send_app_msgs.\n");
999 printf("quitting.\n");
1000 /* Let applications know we are not responding anymore */
1001 ret
= update_futex(wait_shm_fd
, 0);
1003 fprintf(stderr
, "Error wakeup futex\n");