diff options
Diffstat (limited to 'src/libunixonacid/textclient_end.c')
-rw-r--r-- | src/libunixonacid/textclient_end.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libunixonacid/textclient_end.c b/src/libunixonacid/textclient_end.c new file mode 100644 index 0000000..58fc930 --- /dev/null +++ b/src/libunixonacid/textclient_end.c @@ -0,0 +1,22 @@ +/* ISC license. */ + +#include <skalibs/djbunix.h> +#include <skalibs/textmessage.h> +#include <skalibs/textclient.h> + +void textclient_end (textclient_t *a) +{ + fd_close(textmessage_sender_fd(&a->syncout)) ; + if (textmessage_receiver_fd(&a->syncin) != textmessage_sender_fd(&a->syncout)) + fd_close(textmessage_receiver_fd(&a->syncin)) ; + fd_close(textmessage_receiver_fd(&a->asyncin)) ; + textmessage_sender_free(&a->syncout) ; + textmessage_receiver_free(&a->syncin) ; + textmessage_receiver_free(&a->asyncin) ; + if (a->pid && a->options & TEXTCLIENT_OPTION_WAITPID) + { + int wstat ; + waitpid_nointr(a->pid, &wstat, 0) ; + } + *a = textclient_zero ; +} |