comparison rvinterf/tmsh/oneshot.c @ 71:27c41e4b21ae

fc-tmsh one-shot operation mode implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 26 Oct 2016 23:51:47 +0000
parents
children
comparison
equal deleted inserted replaced
70:2c6dca514a20 71:27c41e4b21ae
1 /*
2 * This module implements the one-shot mode of operation for fc-tmsh.
3 */
4
5 #include <sys/types.h>
6 #include <sys/errno.h>
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include "exitcodes.h"
11
12 extern int oneshot_nowait;
13 extern int sock;
14 extern int got_tm_response;
15
16 oneshot_command(argc, argv)
17 char **argv;
18 {
19 fd_set fds;
20 int rc;
21
22 if (!oneshot_nowait)
23 init(); /* to catch the response properly */
24 rc = dispatch_oneshot_cmd(argc, argv);
25 if (rc)
26 exit(rc);
27 if (oneshot_nowait)
28 exit(0);
29 /* wait for response */
30 for (;;) {
31 FD_ZERO(&fds);
32 FD_SET(sock, &fds);
33 rc = select(sock+1, &fds, 0, 0, 0);
34 if (rc < 0) {
35 if (errno == EINTR)
36 continue;
37 perror("select");
38 exit(ERROR_UNIX);
39 }
40 if (FD_ISSET(sock, &fds))
41 handle_rvinterf_input();
42 if (got_tm_response)
43 exit(0);
44 }
45 }