textclient_end.c (715B)
1 /* ISC license. */ 2 3 #include <errno.h> 4 5 #include <skalibs/djbunix.h> 6 #include <skalibs/textmessage.h> 7 #include <skalibs/textclient.h> 8 9 void textclient_end (textclient *a) 10 { 11 fd_close(textmessage_sender_fd(&a->syncout)) ; 12 if (textmessage_receiver_fd(&a->syncin) != textmessage_sender_fd(&a->syncout)) 13 fd_close(textmessage_receiver_fd(&a->syncin)) ; 14 fd_close(textmessage_receiver_fd(&a->asyncin)) ; 15 textmessage_sender_free(&a->syncout) ; 16 textmessage_receiver_free(&a->syncin) ; 17 textmessage_receiver_free(&a->asyncin) ; 18 if (a->pid && a->options & TEXTCLIENT_OPTION_WAITPID) 19 { 20 int e = errno ; 21 int wstat ; 22 waitpid_nointr(a->pid, &wstat, 0) ; 23 errno = e ; 24 } 25 *a = textclient_zero ; 26 }