comparison rvinterf/etm/launchrvif.c @ 197:fa7174faa9aa

fc-tmsh: option to invoke rvinterf "behind the scenes"
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 15 Dec 2013 07:31:52 +0000
parents
children 2847b6cbd915
comparison
equal deleted inserted replaced
196:3daa8ebbe74d 197:fa7174faa9aa
1 /*
2 * This module implements the optional "behind the scenes" invokation
3 * of rvinterf from fc-tmsh.
4 */
5
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11
12 static char rvinterf_pathname[] = "/usr/local/bin/rvinterf";
13
14 extern int sock;
15
16 char *rvinterf_lopt, *rvinterf_wopt;
17
18 launch_rvinterf(ttyport)
19 char *ttyport;
20 {
21 int sp[2], rc;
22 char *rvif_argv[9], Sarg[16], **ap;
23
24 rc = socketpair(AF_UNIX, SOCK_STREAM, 0, sp);
25 if (rc < 0) {
26 perror("socketpair");
27 exit(1);
28 }
29 sock = sp[0];
30 sprintf(Sarg, "-S%d", sp[1]);
31 ap = rvif_argv;
32 *ap++ = "rvinterf";
33 *ap++ = Sarg;
34 *ap++ = "-n";
35 if (rvinterf_lopt) {
36 *ap++ = "-l";
37 *ap++ = rvinterf_lopt;
38 }
39 if (rvinterf_wopt) {
40 *ap++ = "-w";
41 *ap++ = rvinterf_wopt;
42 }
43 *ap++ = ttyport;
44 *ap = 0;
45 rc = vfork();
46 if (rc < 0) {
47 perror("vfork for launching rvinterf");
48 exit(1);
49 }
50 if (!rc) {
51 /* we are in the child - do the exec */
52 close(sp[0]);
53 execv(rvinterf_pathname, rvif_argv);
54 perror(rvinterf_pathname);
55 _exit(1);
56 }
57 close(sp[1]);
58 return 0;
59 }