2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <sys/socket.h>
33 #include <sys/types.h>
36 #include <urcu/list.h> /* URCU list library (-lurcu) */
37 #include <ust/ustctl.h> /* UST control lib (-lust) */
38 #include <lttng/liblttngctl.h>
40 #include "liblttsessiondcomm.h"
41 #include "ltt-sessiond.h"
45 const char default_home_dir
[] = DEFAULT_HOME_DIR
;
46 const char default_tracing_group
[] = DEFAULT_TRACING_GROUP
;
47 const char default_ust_sock_dir
[] = DEFAULT_UST_SOCK_DIR
;
48 const char default_global_apps_pipe
[] = DEFAULT_GLOBAL_APPS_PIPE
;
50 /* Static functions */
51 static int set_signal_handler(void);
52 static int set_socket_perms(void);
53 static void sighandler(int sig
);
54 static void cleanup(void);
55 static void copy_common_data(struct lttcomm_lttng_msg
*llm
, struct lttcomm_session_msg
*lsm
);
56 static int check_existing_daemon(void);
57 static int notify_apps(const char* name
);
58 static int connect_app(pid_t pid
);
59 static int find_app_by_pid(pid_t pid
);
60 static int init_daemon_socket(void);
61 static int process_client_msg(int sock
, struct lttcomm_session_msg
*);
62 static int send_unix_sock(int sock
, void *buf
, size_t len
);
63 static int setup_data_buffer(char **buf
, size_t size
, struct lttcomm_lttng_msg
*llm
);
64 static void add_traceable_app(struct ltt_traceable_app
*lta
);
65 static void del_traceable_app(struct ltt_traceable_app
*lta
);
66 static void add_session_list(struct ltt_session
*ls
);
67 static void del_session_list(struct ltt_session
*ls
);
69 /* Command function */
70 static void get_list_apps(pid_t
*pids
);
71 static void get_list_sessions(struct lttng_session
*lt
);
73 static void *thread_manage_clients(void *data
);
74 static void *thread_manage_apps(void *data
);
76 static int create_session(char *name
, uuid_t
*session_id
);
77 static int destroy_session(uuid_t
*uuid
);
79 static struct ltt_session
*find_session_by_uuid(uuid_t session_id
);
80 static struct ltt_session
*find_session_by_name(char *name
);
84 const char *opt_tracing_group
;
85 static int opt_sig_parent
;
86 static int opt_daemon
;
89 static int is_root
; /* Set to 1 if the daemon is running as root */
92 static char apps_unix_sock_path
[PATH_MAX
]; /* Global application Unix socket path */
93 static char client_unix_sock_path
[PATH_MAX
]; /* Global client Unix socket path */
95 static int client_socket
;
96 static int apps_socket
;
98 static struct ltt_session
*current_session
;
100 /* Number of element for the list below. */
101 static unsigned int session_count
;
102 static unsigned int traceable_app_count
;
104 /* Init session's list */
105 static struct ltt_session_list ltt_session_list
= {
106 .head
= CDS_LIST_HEAD_INIT(ltt_session_list
.head
),
109 /* Init ust traceabl application's list */
110 static struct ltt_traceable_app_list ltt_traceable_app_list
= {
111 .head
= CDS_LIST_HEAD_INIT(ltt_traceable_app_list
.head
),
115 pthread_mutex_t ltt_traceable_app_list_mutex
;
120 * This thread manage the application socket communication
122 static void *thread_manage_apps(void *data
)
125 struct ltt_traceable_app
*lta
;
127 /* TODO: Something more elegant is needed but fine for now */
129 int reg
; /* 1:register, 0:unregister */
134 /* Notify all applications to register */
135 notify_apps(default_global_apps_pipe
);
137 ret
= lttcomm_listen_unix_sock(apps_socket
);
143 /* Blocking call, waiting for transmission */
144 sock
= lttcomm_accept_unix_sock(apps_socket
);
149 /* Basic recv here to handle the very simple data
150 * that the libust send to register (reg_msg).
152 ret
= recv(sock
, ®_msg
, sizeof(reg_msg
), 0);
158 /* Add application to the global traceable list */
159 if (reg_msg
.reg
== 1) {
161 lta
= malloc(sizeof(struct ltt_traceable_app
));
162 lta
->pid
= reg_msg
.pid
;
163 lta
->uid
= reg_msg
.uid
;
164 add_traceable_app(lta
);
167 cds_list_for_each_entry(lta
, <t_traceable_app_list
.head
, list
) {
168 if (lta
->pid
== reg_msg
.pid
&& lta
->uid
== reg_msg
.uid
) {
169 del_traceable_app(lta
);
183 * thread_manage_clients
185 * This thread manage all clients request using the unix
186 * client socket for communication.
188 static void *thread_manage_clients(void *data
)
191 struct lttcomm_session_msg lsm
;
193 ret
= lttcomm_listen_unix_sock(client_socket
);
198 /* Notify parent pid that we are ready
199 * to accept command for client side.
201 if (opt_sig_parent
) {
206 /* Blocking call, waiting for transmission */
207 sock
= lttcomm_accept_unix_sock(client_socket
);
213 * Data is received from the lttng client. The struct
214 * lttcomm_session_msg (lsm) contains the command and data
215 * request of the client.
217 ret
= lttcomm_recv_unix_sock(sock
, &lsm
, sizeof(lsm
));
222 /* This function dispatch the work to the LTTng or UST libs
223 * and then sends back the response to the client. This is needed
224 * because there might be more then one lttcomm_lttng_msg to
225 * send out so process_client_msg do both jobs.
227 ret
= process_client_msg(sock
, &lsm
);
229 /* Error detected but still accept command */
241 * Add a traceable application structure to the global
242 * list protected by a mutex.
244 static void add_traceable_app(struct ltt_traceable_app
*lta
)
246 pthread_mutex_lock(<t_traceable_app_list_mutex
);
247 cds_list_add(<a
->list
, <t_traceable_app_list
.head
);
248 traceable_app_count
++;
249 pthread_mutex_unlock(<t_traceable_app_list_mutex
);
255 * Delete a traceable application structure from the
256 * global list protected by a mutex.
258 static void del_traceable_app(struct ltt_traceable_app
*lta
)
260 pthread_mutex_lock(<t_traceable_app_list_mutex
);
261 cds_list_del(<a
->list
);
263 if (traceable_app_count
!= 0) {
264 traceable_app_count
--;
266 pthread_mutex_unlock(<t_traceable_app_list_mutex
);
272 * Add a ltt_session structure to the global list.
274 static void add_session_list(struct ltt_session
*ls
)
276 cds_list_add(&ls
->list
, <t_session_list
.head
);
283 * Delete a ltt_session structure to the global list.
285 static void del_session_list(struct ltt_session
*ls
)
287 cds_list_del(&ls
->list
);
289 if (session_count
!= 0) {
297 * Send data on a unix socket using the liblttsessiondcomm API.
299 * Return lttcomm error code.
301 static int send_unix_sock(int sock
, void *buf
, size_t len
)
303 /* Check valid length */
308 return lttcomm_send_unix_sock(sock
, buf
, len
);
314 * Return a socket connected to the libust communication socket
315 * of the application identified by the pid.
317 * If the pid is not found in the traceable list,
318 * return -1 to indicate error.
320 static int connect_app(pid_t pid
)
324 ret
= find_app_by_pid(pid
);
329 sock
= ustctl_connect_pid(pid
);
331 ERR("Fail connecting to the PID %d\n", pid
);
340 * Notify apps by writing 42 to a named pipe using name.
341 * Every applications waiting for a ltt-sessiond will be notified
342 * and re-register automatically to the session daemon.
344 * Return open or write error value.
346 static int notify_apps(const char *name
)
351 /* Try opening the global pipe */
352 fd
= open(name
, O_WRONLY
);
357 /* Notify by writing on the pipe */
358 ret
= write(fd
, "42", 2);
370 * Iterate over the traceable apps list.
371 * On success, return 1, else return 0
373 static int find_app_by_pid(pid_t pid
)
375 struct ltt_traceable_app
*iter
;
377 pthread_mutex_lock(<t_traceable_app_list_mutex
);
378 cds_list_for_each_entry(iter
, <t_traceable_app_list
.head
, list
) {
379 if (iter
->pid
== pid
) {
380 pthread_mutex_unlock(<t_traceable_app_list_mutex
);
385 pthread_mutex_unlock(<t_traceable_app_list_mutex
);
391 * find_session_by_uuid
393 * Return a ltt_session structure ptr that matches the uuid.
395 static struct ltt_session
*find_session_by_uuid(uuid_t session_id
)
398 struct ltt_session
*iter
;
400 /* Sanity check for NULL session_id */
401 if (uuid_is_null(session_id
)) {
405 cds_list_for_each_entry(iter
, <t_session_list
.head
, list
) {
406 if (uuid_compare(iter
->uuid
, session_id
) == 0) {
420 * find_session_by_name
422 * Return a ltt_session structure ptr that matches name.
423 * If no session found, NULL is returned.
425 static struct ltt_session
*find_session_by_name(char *name
)
428 struct ltt_session
*iter
;
430 cds_list_for_each_entry(iter
, <t_session_list
.head
, list
) {
431 if (strncmp(iter
->name
, name
, strlen(iter
->name
)) == 0) {
447 * Delete session from the global session list
448 * and free the memory.
450 * Return -1 if no session is found.
451 * On success, return 1;
453 static int destroy_session(uuid_t
*uuid
)
456 struct ltt_session
*iter
;
458 cds_list_for_each_entry(iter
, <t_session_list
.head
, list
) {
459 if (uuid_compare(iter
->uuid
, *uuid
) == 0) {
460 del_session_list(iter
);
473 * Create a brand new session and add it to the
474 * global session list.
476 static int create_session(char *name
, uuid_t
*session_id
)
478 struct ltt_session
*new_session
;
480 /* Allocate session data structure */
481 new_session
= malloc(sizeof(struct ltt_session
));
482 if (new_session
== NULL
) {
488 if (asprintf(&new_session
->name
, "%s", name
) < 0) {
492 /* Generate session name based on the session count */
493 if (asprintf(&new_session
->name
, "%s%d", "lttng-", session_count
) < 0) {
498 /* UUID generation */
499 uuid_generate(new_session
->uuid
);
500 uuid_copy(*session_id
, new_session
->uuid
);
502 /* Set consumer (identifier) to 0. This means that there is
503 * NO consumer attach to that session yet.
505 new_session
->ust_consumer
= 0;
506 new_session
->lttng_consumer
= 0;
509 CDS_INIT_LIST_HEAD(&new_session
->ust_traces
);
510 CDS_INIT_LIST_HEAD(&new_session
->lttng_traces
);
512 /* Add new session to the global session list */
513 add_session_list(new_session
);
524 * Create an userspace trace using pid.
525 * This trace is then appended to the current session
528 static int ust_create_trace(pid_t pid
)
531 struct ltt_ust_trace
*trace
;
533 trace
= malloc(sizeof(struct ltt_ust_trace
));
544 /* Connect to app using ustctl API */
545 sock
= connect_app(pid
);
547 ret
= LTTCOMM_NO_TRACEABLE
;
551 ret
= ustctl_create_trace(sock
, "auto");
553 ret
= LTTCOMM_CREATE_FAIL
;
557 /* Check if current session is valid */
558 if (current_session
) {
559 cds_list_add(&trace
->list
, ¤t_session
->ust_traces
);
569 * List traceable user-space application and fill an
572 static void get_list_apps(pid_t
*pids
)
575 struct ltt_traceable_app
*iter
;
577 /* Protected by a mutex here because the threads manage_client
578 * and manage_apps can access this list.
580 pthread_mutex_lock(<t_traceable_app_list_mutex
);
581 cds_list_for_each_entry(iter
, <t_traceable_app_list
.head
, list
) {
585 pthread_mutex_unlock(<t_traceable_app_list_mutex
);
591 * List sessions and fill the data buffer.
593 static void get_list_sessions(struct lttng_session
*lt
)
596 struct ltt_session
*iter
;
597 struct lttng_session lsess
;
599 /* Iterate over session list and append data after
600 * the control struct in the buffer.
602 cds_list_for_each_entry(iter
, <t_session_list
.head
, list
) {
603 /* Copy name and uuid */
604 uuid_unparse(iter
->uuid
, lsess
.uuid
);
605 strncpy(lsess
.name
, iter
->name
, sizeof(lsess
.name
));
606 lsess
.name
[sizeof(lsess
.name
) - 1] = '\0';
607 memcpy(<
[i
], &lsess
, sizeof(lsess
));
609 /* Reset struct for next pass */
610 memset(&lsess
, 0, sizeof(lsess
));
617 * Copy common data between lttcomm_lttng_msg and lttcomm_session_msg
619 static void copy_common_data(struct lttcomm_lttng_msg
*llm
, struct lttcomm_session_msg
*lsm
)
621 llm
->cmd_type
= lsm
->cmd_type
;
625 if (!uuid_is_null(lsm
->session_id
)) {
626 uuid_copy(llm
->session_id
, lsm
->session_id
);
629 strncpy(llm
->trace_name
, lsm
->trace_name
, strlen(llm
->trace_name
));
630 llm
->trace_name
[strlen(llm
->trace_name
) - 1] = '\0';
636 * Setup the outgoing data buffer for the response
637 * data allocating the right amount of memory.
639 * Return total size of the buffer pointed by buf.
641 static int setup_data_buffer(char **buf
, size_t s_data
, struct lttcomm_lttng_msg
*llm
)
646 buf_size
= sizeof(struct lttcomm_lttng_msg
) + s_data
;
647 *buf
= malloc(buf_size
);
654 /* Setup lttcomm_lttng_msg data and copy
655 * it to the newly allocated buffer.
657 llm
->size_payload
= s_data
;
658 memcpy(*buf
, llm
, sizeof(struct lttcomm_lttng_msg
));
669 * This takes the lttcomm_session_msg struct and process the command requested
670 * by the client. It then creates response(s) and send it back to the
671 * given socket (sock).
673 * Return any error encountered or 0 for success.
675 static int process_client_msg(int sock
, struct lttcomm_session_msg
*lsm
)
679 char *send_buf
= NULL
;
680 struct lttcomm_lttng_msg llm
;
682 /* Copy common data to identify the response
683 * on the lttng client side.
685 copy_common_data(&llm
, lsm
);
687 /* Check command that needs a session */
688 if (lsm
->cmd_type
!= LTTNG_CREATE_SESSION
&&
689 lsm
->cmd_type
!= LTTNG_LIST_SESSIONS
&&
690 lsm
->cmd_type
!= UST_LIST_APPS
)
692 current_session
= find_session_by_uuid(lsm
->session_id
);
693 if (current_session
== NULL
) {
694 ret
= LTTCOMM_SELECT_SESS
;
700 /* Default return code.
701 * In our world, everything is OK... right? ;)
703 llm
.ret_code
= LTTCOMM_OK
;
705 /* Process by command type */
706 switch (lsm
->cmd_type
) {
707 case LTTNG_CREATE_SESSION
:
709 ret
= create_session(lsm
->session_name
, &llm
.session_id
);
714 buf_size
= setup_data_buffer(&send_buf
, 0, &llm
);
722 case LTTNG_DESTROY_SESSION
:
724 ret
= destroy_session(&lsm
->session_id
);
726 ret
= LTTCOMM_NO_SESS
;
731 /* No auxiliary data so only send the llm struct. */
734 case UST_CREATE_TRACE
:
736 ret
= ust_create_trace(lsm
->pid
);
738 ret
= LTTCOMM_CREATE_FAIL
;
742 /* No auxiliary data so only send the llm struct. */
747 /* Stop right now if no apps */
748 if (traceable_app_count
== 0) {
749 ret
= LTTCOMM_NO_APPS
;
753 /* Setup data buffer and details for transmission */
754 buf_size
= setup_data_buffer(&send_buf
,
755 sizeof(pid_t
) * traceable_app_count
, &llm
);
761 get_list_apps((pid_t
*)(send_buf
+ sizeof(struct lttcomm_lttng_msg
)));
765 case LTTNG_LIST_SESSIONS
:
767 /* Stop right now if no session */
768 if (session_count
== 0) {
769 ret
= LTTCOMM_NO_SESS
;
773 /* Setup data buffer and details for transmission */
774 buf_size
= setup_data_buffer(&send_buf
,
775 (sizeof(struct lttng_session
) * session_count
), &llm
);
781 get_list_sessions((struct lttng_session
*)(send_buf
+ sizeof(struct lttcomm_lttng_msg
)));
787 /* Undefined command */
793 ret
= send_unix_sock(sock
, send_buf
, buf_size
);
795 if (send_buf
!= NULL
) {
802 /* Notify client of error */
804 llm
.size_payload
= 0;
805 send_unix_sock(sock
, (void*) &llm
, sizeof(llm
));
811 * usage function on stderr
813 static void usage(void)
815 fprintf(stderr
, "Usage: %s OPTIONS\n\nOptions:\n", progname
);
816 fprintf(stderr
, " -h, --help Display this usage.\n");
817 fprintf(stderr
, " -c, --client-sock PATH Specify path for the client unix socket\n");
818 fprintf(stderr
, " -a, --apps-sock PATH Specify path for apps unix socket.\n");
819 fprintf(stderr
, " -d, --daemonize Start as a daemon.\n");
820 fprintf(stderr
, " -g, --group NAME Specify the tracing group name. (default: tracing)\n");
821 fprintf(stderr
, " -V, --version Show version number.\n");
822 fprintf(stderr
, " -S, --sig-parent Send SIGCHLD to parent pid to notify readiness.\n");
823 fprintf(stderr
, " -q, --quiet No output at all.\n");
827 * daemon argument parsing
829 static int parse_args(int argc
, char **argv
)
833 static struct option long_options
[] = {
834 { "client-sock", 1, 0, 'c' },
835 { "apps-sock", 1, 0, 'a' },
836 { "daemonize", 0, 0, 'd' },
837 { "sig-parent", 0, 0, 'S' },
838 { "help", 0, 0, 'h' },
839 { "group", 1, 0, 'g' },
840 { "version", 0, 0, 'V' },
841 { "quiet", 0, 0, 'q' },
846 int option_index
= 0;
847 c
= getopt_long(argc
, argv
, "dhqVS" "a:c:g:s:", long_options
, &option_index
);
854 fprintf(stderr
, "option %s", long_options
[option_index
].name
);
856 fprintf(stderr
, " with arg %s\n", optarg
);
860 snprintf(client_unix_sock_path
, PATH_MAX
, "%s", optarg
);
863 snprintf(apps_unix_sock_path
, PATH_MAX
, "%s", optarg
);
869 opt_tracing_group
= strdup(optarg
);
875 fprintf(stdout
, "%s\n", VERSION
);
884 /* Unknown option or other error.
885 * Error is printed by getopt, just return */
896 * Creates the two needed socket by the daemon.
897 * apps_socket - The communication socket for all UST apps.
898 * client_socket - The communication of the cli tool (lttng).
900 static int init_daemon_socket()
905 old_umask
= umask(0);
907 /* Create client tool unix socket */
908 client_socket
= lttcomm_create_unix_sock(client_unix_sock_path
);
909 if (client_socket
< 0) {
914 /* File permission MUST be 660 */
915 ret
= chmod(client_unix_sock_path
, S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
);
921 /* Create the application unix socket */
922 apps_socket
= lttcomm_create_unix_sock(apps_unix_sock_path
);
923 if (apps_socket
< 0) {
928 /* File permission MUST be 660 */
929 ret
= chmod(apps_unix_sock_path
, S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
| S_IROTH
| S_IWOTH
);
941 * check_existing_daemon
943 * Check if the global socket is available.
944 * If yes, error is returned.
946 static int check_existing_daemon()
950 ret
= access(client_unix_sock_path
, F_OK
);
952 ret
= access(apps_unix_sock_path
, F_OK
);
961 * Return pointer to home directory path using
962 * the env variable HOME.
966 static const char *get_home_dir(void)
968 const char *home_path
;
970 if ((home_path
= (const char *) getenv("HOME")) == NULL
) {
971 home_path
= default_home_dir
;
980 * Set the tracing group gid onto the client socket.
982 static int set_socket_perms(void)
987 /* Decide which group name to use */
988 (opt_tracing_group
!= NULL
) ?
989 (grp
= getgrnam(opt_tracing_group
)) :
990 (grp
= getgrnam(default_tracing_group
));
993 ERR("Missing tracing group. Aborting execution.\n");
998 ret
= chown(client_unix_sock_path
, 0, grp
->gr_gid
);
1008 * set_signal_handler
1010 * Setup signal handler for :
1011 * SIGINT, SIGTERM, SIGPIPE
1013 static int set_signal_handler(void)
1016 struct sigaction sa
;
1019 if ((ret
= sigemptyset(&sigset
)) < 0) {
1020 perror("sigemptyset");
1024 sa
.sa_handler
= sighandler
;
1025 sa
.sa_mask
= sigset
;
1027 if ((ret
= sigaction(SIGTERM
, &sa
, NULL
)) < 0) {
1028 perror("sigaction");
1032 if ((ret
= sigaction(SIGINT
, &sa
, NULL
)) < 0) {
1033 perror("sigaction");
1037 if ((ret
= sigaction(SIGPIPE
, &sa
, NULL
)) < 0) {
1038 perror("sigaction");
1048 * Signal handler for the daemon
1050 static void sighandler(int sig
)
1069 * Cleanup the daemon on exit
1071 static void cleanup()
1074 MSG("\n%c[%d;%dm*** assert failed *** ==> %c[%dm", 27,1,31,27,0);
1075 MSG("%c[%d;%dmMatthew, BEET driven development works!%c[%dm",27,1,33,27,0);
1078 unlink(client_unix_sock_path
);
1079 unlink(apps_unix_sock_path
);
1085 int main(int argc
, char **argv
)
1090 pthread_t threads
[2];
1092 /* Parse arguments */
1094 if ((ret
= parse_args(argc
, argv
) < 0)) {
1107 /* Check if daemon is UID = 0 */
1108 is_root
= !getuid();
1110 /* Set all sockets path */
1112 if (strlen(apps_unix_sock_path
) == 0) {
1113 (snprintf(apps_unix_sock_path
, PATH_MAX
,
1114 DEFAULT_GLOBAL_APPS_UNIX_SOCK
));
1117 if (strlen(client_unix_sock_path
) == 0) {
1118 (snprintf(client_unix_sock_path
, PATH_MAX
,
1119 DEFAULT_GLOBAL_CLIENT_UNIX_SOCK
));
1122 if (strlen(apps_unix_sock_path
) == 0) {
1123 (snprintf(apps_unix_sock_path
, PATH_MAX
,
1124 DEFAULT_HOME_APPS_UNIX_SOCK
, get_home_dir()));
1127 /* Set the cli tool unix socket path */
1128 if (strlen(client_unix_sock_path
) == 0) {
1129 (snprintf(client_unix_sock_path
, PATH_MAX
,
1130 DEFAULT_HOME_CLIENT_UNIX_SOCK
, get_home_dir()));
1134 /* See if daemon already exist. If any of the two
1135 * socket needed by the daemon are present, this test fails
1137 if ((ret
= check_existing_daemon()) == 0) {
1138 ERR("Already running daemon.\n");
1142 if (set_signal_handler() < 0) {
1146 /* Setup the two needed unix socket */
1147 if (init_daemon_socket() < 0) {
1151 /* Set credentials to socket */
1152 if (is_root
&& (set_socket_perms() < 0)) {
1156 /* Get parent pid if -S, --sig-parent is specified. */
1157 if (opt_sig_parent
) {
1162 /* Create thread to manage the client socket */
1163 ret
= pthread_create(&threads
[0], NULL
, thread_manage_clients
, (void *) NULL
);
1165 perror("pthread_create");
1169 /* Create thread to manage application socket */
1170 ret
= pthread_create(&threads
[1], NULL
, thread_manage_apps
, (void *) NULL
);
1172 perror("pthread_create");
1176 for (i
= 0; i
< 2; i
++) {
1177 ret
= pthread_join(threads
[i
], &status
);
1179 perror("pthread_join");
1191 return EXIT_FAILURE
;