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 new_session
= find_session_by_name(name
);
481 if (new_session
!= NULL
) {
485 /* Allocate session data structure */
486 new_session
= malloc(sizeof(struct ltt_session
));
487 if (new_session
== NULL
) {
493 if (asprintf(&new_session
->name
, "%s", name
) < 0) {
497 /* Generate session name based on the session count */
498 if (asprintf(&new_session
->name
, "%s%d", "lttng-", session_count
) < 0) {
503 /* UUID generation */
504 uuid_generate(new_session
->uuid
);
505 uuid_copy(*session_id
, new_session
->uuid
);
507 /* Set consumer (identifier) to 0. This means that there is
508 * NO consumer attach to that session yet.
510 new_session
->ust_consumer
= 0;
511 new_session
->lttng_consumer
= 0;
514 CDS_INIT_LIST_HEAD(&new_session
->ust_traces
);
515 CDS_INIT_LIST_HEAD(&new_session
->lttng_traces
);
517 /* Add new session to the global session list */
518 add_session_list(new_session
);
532 * Create an userspace trace using pid.
533 * This trace is then appended to the current session
536 static int ust_create_trace(pid_t pid
)
539 struct ltt_ust_trace
*trace
;
541 trace
= malloc(sizeof(struct ltt_ust_trace
));
552 /* Connect to app using ustctl API */
553 sock
= connect_app(pid
);
555 ret
= LTTCOMM_NO_TRACEABLE
;
559 ret
= ustctl_create_trace(sock
, "auto");
561 ret
= LTTCOMM_CREATE_FAIL
;
565 /* Check if current session is valid */
566 if (current_session
) {
567 cds_list_add(&trace
->list
, ¤t_session
->ust_traces
);
577 * List traceable user-space application and fill an
580 static void get_list_apps(pid_t
*pids
)
583 struct ltt_traceable_app
*iter
;
585 /* Protected by a mutex here because the threads manage_client
586 * and manage_apps can access this list.
588 pthread_mutex_lock(<t_traceable_app_list_mutex
);
589 cds_list_for_each_entry(iter
, <t_traceable_app_list
.head
, list
) {
593 pthread_mutex_unlock(<t_traceable_app_list_mutex
);
599 * List sessions and fill the data buffer.
601 static void get_list_sessions(struct lttng_session
*lt
)
604 struct ltt_session
*iter
;
605 struct lttng_session lsess
;
607 /* Iterate over session list and append data after
608 * the control struct in the buffer.
610 cds_list_for_each_entry(iter
, <t_session_list
.head
, list
) {
611 /* Copy name and uuid */
612 uuid_unparse(iter
->uuid
, lsess
.uuid
);
613 strncpy(lsess
.name
, iter
->name
, sizeof(lsess
.name
));
614 lsess
.name
[sizeof(lsess
.name
) - 1] = '\0';
615 memcpy(<
[i
], &lsess
, sizeof(lsess
));
617 /* Reset struct for next pass */
618 memset(&lsess
, 0, sizeof(lsess
));
625 * Copy common data between lttcomm_lttng_msg and lttcomm_session_msg
627 static void copy_common_data(struct lttcomm_lttng_msg
*llm
, struct lttcomm_session_msg
*lsm
)
629 llm
->cmd_type
= lsm
->cmd_type
;
633 if (!uuid_is_null(lsm
->session_id
)) {
634 uuid_copy(llm
->session_id
, lsm
->session_id
);
637 strncpy(llm
->trace_name
, lsm
->trace_name
, strlen(llm
->trace_name
));
638 llm
->trace_name
[strlen(llm
->trace_name
) - 1] = '\0';
644 * Setup the outgoing data buffer for the response
645 * data allocating the right amount of memory.
647 * Return total size of the buffer pointed by buf.
649 static int setup_data_buffer(char **buf
, size_t s_data
, struct lttcomm_lttng_msg
*llm
)
654 buf_size
= sizeof(struct lttcomm_lttng_msg
) + s_data
;
655 *buf
= malloc(buf_size
);
662 /* Setup lttcomm_lttng_msg data and copy
663 * it to the newly allocated buffer.
665 llm
->size_payload
= s_data
;
666 memcpy(*buf
, llm
, sizeof(struct lttcomm_lttng_msg
));
677 * This takes the lttcomm_session_msg struct and process the command requested
678 * by the client. It then creates response(s) and send it back to the
679 * given socket (sock).
681 * Return any error encountered or 0 for success.
683 static int process_client_msg(int sock
, struct lttcomm_session_msg
*lsm
)
688 char *send_buf
= NULL
;
689 struct lttcomm_lttng_msg llm
;
691 /* Copy common data to identify the response
692 * on the lttng client side.
694 copy_common_data(&llm
, lsm
);
696 /* Check command that needs a session */
697 if (lsm
->cmd_type
!= LTTNG_CREATE_SESSION
&&
698 lsm
->cmd_type
!= LTTNG_LIST_SESSIONS
&&
699 lsm
->cmd_type
!= UST_LIST_APPS
)
701 current_session
= find_session_by_uuid(lsm
->session_id
);
702 if (current_session
== NULL
) {
703 ret
= LTTCOMM_SELECT_SESS
;
708 /* Default return code.
709 * In our world, everything is OK... right? ;)
711 llm
.ret_code
= LTTCOMM_OK
;
713 header_size
= sizeof(struct lttcomm_lttng_msg
);
715 /* Process by command type */
716 switch (lsm
->cmd_type
) {
717 case LTTNG_CREATE_SESSION
:
719 ret
= create_session(lsm
->session_name
, &llm
.session_id
);
722 ret
= LTTCOMM_EXIST_SESS
;
729 buf_size
= setup_data_buffer(&send_buf
, 0, &llm
);
737 case LTTNG_DESTROY_SESSION
:
739 ret
= destroy_session(&lsm
->session_id
);
741 ret
= LTTCOMM_NO_SESS
;
746 /* No auxiliary data so only send the llm struct. */
749 case UST_CREATE_TRACE
:
751 ret
= ust_create_trace(lsm
->pid
);
753 ret
= LTTCOMM_CREATE_FAIL
;
757 /* No auxiliary data so only send the llm struct. */
762 /* Stop right now if no apps */
763 if (traceable_app_count
== 0) {
764 ret
= LTTCOMM_NO_APPS
;
768 /* Setup data buffer and details for transmission */
769 buf_size
= setup_data_buffer(&send_buf
,
770 sizeof(pid_t
) * traceable_app_count
, &llm
);
776 get_list_apps((pid_t
*)(send_buf
+ header_size
));
780 case LTTNG_LIST_SESSIONS
:
782 /* Stop right now if no session */
783 if (session_count
== 0) {
784 ret
= LTTCOMM_NO_SESS
;
788 /* Setup data buffer and details for transmission */
789 buf_size
= setup_data_buffer(&send_buf
,
790 (sizeof(struct lttng_session
) * session_count
), &llm
);
796 get_list_sessions((struct lttng_session
*)(send_buf
+ header_size
));
802 /* Undefined command */
808 ret
= send_unix_sock(sock
, send_buf
, buf_size
);
810 if (send_buf
!= NULL
) {
817 /* Notify client of error */
819 llm
.size_payload
= 0;
820 send_unix_sock(sock
, (void*) &llm
, sizeof(llm
));
826 * usage function on stderr
828 static void usage(void)
830 fprintf(stderr
, "Usage: %s OPTIONS\n\nOptions:\n", progname
);
831 fprintf(stderr
, " -h, --help Display this usage.\n");
832 fprintf(stderr
, " -c, --client-sock PATH Specify path for the client unix socket\n");
833 fprintf(stderr
, " -a, --apps-sock PATH Specify path for apps unix socket.\n");
834 fprintf(stderr
, " -d, --daemonize Start as a daemon.\n");
835 fprintf(stderr
, " -g, --group NAME Specify the tracing group name. (default: tracing)\n");
836 fprintf(stderr
, " -V, --version Show version number.\n");
837 fprintf(stderr
, " -S, --sig-parent Send SIGCHLD to parent pid to notify readiness.\n");
838 fprintf(stderr
, " -q, --quiet No output at all.\n");
842 * daemon argument parsing
844 static int parse_args(int argc
, char **argv
)
848 static struct option long_options
[] = {
849 { "client-sock", 1, 0, 'c' },
850 { "apps-sock", 1, 0, 'a' },
851 { "daemonize", 0, 0, 'd' },
852 { "sig-parent", 0, 0, 'S' },
853 { "help", 0, 0, 'h' },
854 { "group", 1, 0, 'g' },
855 { "version", 0, 0, 'V' },
856 { "quiet", 0, 0, 'q' },
861 int option_index
= 0;
862 c
= getopt_long(argc
, argv
, "dhqVS" "a:c:g:s:", long_options
, &option_index
);
869 fprintf(stderr
, "option %s", long_options
[option_index
].name
);
871 fprintf(stderr
, " with arg %s\n", optarg
);
875 snprintf(client_unix_sock_path
, PATH_MAX
, "%s", optarg
);
878 snprintf(apps_unix_sock_path
, PATH_MAX
, "%s", optarg
);
884 opt_tracing_group
= strdup(optarg
);
890 fprintf(stdout
, "%s\n", VERSION
);
899 /* Unknown option or other error.
900 * Error is printed by getopt, just return */
911 * Creates the two needed socket by the daemon.
912 * apps_socket - The communication socket for all UST apps.
913 * client_socket - The communication of the cli tool (lttng).
915 static int init_daemon_socket()
920 old_umask
= umask(0);
922 /* Create client tool unix socket */
923 client_socket
= lttcomm_create_unix_sock(client_unix_sock_path
);
924 if (client_socket
< 0) {
929 /* File permission MUST be 660 */
930 ret
= chmod(client_unix_sock_path
, S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
);
936 /* Create the application unix socket */
937 apps_socket
= lttcomm_create_unix_sock(apps_unix_sock_path
);
938 if (apps_socket
< 0) {
943 /* File permission MUST be 660 */
944 ret
= chmod(apps_unix_sock_path
, S_IRUSR
| S_IWUSR
| S_IRGRP
| S_IWGRP
| S_IROTH
| S_IWOTH
);
956 * check_existing_daemon
958 * Check if the global socket is available.
959 * If yes, error is returned.
961 static int check_existing_daemon()
965 ret
= access(client_unix_sock_path
, F_OK
);
967 ret
= access(apps_unix_sock_path
, F_OK
);
976 * Return pointer to home directory path using
977 * the env variable HOME.
981 static const char *get_home_dir(void)
983 const char *home_path
;
985 if ((home_path
= (const char *) getenv("HOME")) == NULL
) {
986 home_path
= default_home_dir
;
995 * Set the tracing group gid onto the client socket.
997 static int set_socket_perms(void)
1002 /* Decide which group name to use */
1003 (opt_tracing_group
!= NULL
) ?
1004 (grp
= getgrnam(opt_tracing_group
)) :
1005 (grp
= getgrnam(default_tracing_group
));
1008 ERR("Missing tracing group. Aborting execution.\n");
1013 ret
= chown(client_unix_sock_path
, 0, grp
->gr_gid
);
1023 * set_signal_handler
1025 * Setup signal handler for :
1026 * SIGINT, SIGTERM, SIGPIPE
1028 static int set_signal_handler(void)
1031 struct sigaction sa
;
1034 if ((ret
= sigemptyset(&sigset
)) < 0) {
1035 perror("sigemptyset");
1039 sa
.sa_handler
= sighandler
;
1040 sa
.sa_mask
= sigset
;
1042 if ((ret
= sigaction(SIGTERM
, &sa
, NULL
)) < 0) {
1043 perror("sigaction");
1047 if ((ret
= sigaction(SIGINT
, &sa
, NULL
)) < 0) {
1048 perror("sigaction");
1052 if ((ret
= sigaction(SIGPIPE
, &sa
, NULL
)) < 0) {
1053 perror("sigaction");
1063 * Signal handler for the daemon
1065 static void sighandler(int sig
)
1084 * Cleanup the daemon on exit
1086 static void cleanup()
1089 MSG("\n%c[%d;%dm*** assert failed *** ==> %c[%dm", 27,1,31,27,0);
1090 MSG("%c[%d;%dmMatthew, BEET driven development works!%c[%dm",27,1,33,27,0);
1093 unlink(client_unix_sock_path
);
1094 unlink(apps_unix_sock_path
);
1100 int main(int argc
, char **argv
)
1105 pthread_t threads
[2];
1107 /* Parse arguments */
1109 if ((ret
= parse_args(argc
, argv
) < 0)) {
1122 /* Check if daemon is UID = 0 */
1123 is_root
= !getuid();
1125 /* Set all sockets path */
1127 if (strlen(apps_unix_sock_path
) == 0) {
1128 (snprintf(apps_unix_sock_path
, PATH_MAX
,
1129 DEFAULT_GLOBAL_APPS_UNIX_SOCK
));
1132 if (strlen(client_unix_sock_path
) == 0) {
1133 (snprintf(client_unix_sock_path
, PATH_MAX
,
1134 DEFAULT_GLOBAL_CLIENT_UNIX_SOCK
));
1137 if (strlen(apps_unix_sock_path
) == 0) {
1138 (snprintf(apps_unix_sock_path
, PATH_MAX
,
1139 DEFAULT_HOME_APPS_UNIX_SOCK
, get_home_dir()));
1142 /* Set the cli tool unix socket path */
1143 if (strlen(client_unix_sock_path
) == 0) {
1144 (snprintf(client_unix_sock_path
, PATH_MAX
,
1145 DEFAULT_HOME_CLIENT_UNIX_SOCK
, get_home_dir()));
1149 /* See if daemon already exist. If any of the two
1150 * socket needed by the daemon are present, this test fails
1152 if ((ret
= check_existing_daemon()) == 0) {
1153 ERR("Already running daemon.\n");
1154 /* We do not goto error because we must not
1155 * cleanup() because a daemon is already working.
1157 return EXIT_FAILURE
;
1160 if (set_signal_handler() < 0) {
1164 /* Setup the two needed unix socket */
1165 if (init_daemon_socket() < 0) {
1169 /* Set credentials to socket */
1170 if (is_root
&& (set_socket_perms() < 0)) {
1174 /* Get parent pid if -S, --sig-parent is specified. */
1175 if (opt_sig_parent
) {
1180 /* Create thread to manage the client socket */
1181 ret
= pthread_create(&threads
[0], NULL
, thread_manage_clients
, (void *) NULL
);
1183 perror("pthread_create");
1187 /* Create thread to manage application socket */
1188 ret
= pthread_create(&threads
[1], NULL
, thread_manage_apps
, (void *) NULL
);
1190 perror("pthread_create");
1194 for (i
= 0; i
< 2; i
++) {
1195 ret
= pthread_join(threads
[i
], &status
);
1197 perror("pthread_join");
1209 return EXIT_FAILURE
;