The function
pthread_join(thread, ptr)
provides a way to wait for a thread to terminate and get its exit/return value.
-
First argument is the thread id of the thread to wait for.
-
The second (if not 0) indicates where the return value should go.
-
The return value is 0 if successful or else an error number.
void rlogind(int r_in, int r_out, int l_in, int l_out) { pthread_t in_thread, out_thread; fd_pair_t in = {r_in, l_in}; fd_pair_t out = {r_out, l_out}; pthread_create(&in_thread, 0, incoming, (void *) &in); pthread_create(&out_thread, 0, outgoing, (void *) &out); pthread_join(in_thread, 0); pthread_join(out_thread, 0); }