comparison rvinterf/tmsh/launchrvif.c @ 260:c146f38d2b5f

rvinterf subdir structure made a little more sensible
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Wed, 05 Feb 2014 04:02:13 +0000
parents rvinterf/etm/launchrvif.c@2847b6cbd915
children
comparison
equal deleted inserted replaced
259:35113b1964d3 260:c146f38d2b5f
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_Bopt, *rvinterf_lopt, *rvinterf_wopt;
17
18 launch_rvinterf(ttyport)
19 char *ttyport;
20 {
21 int sp[2], rc;
22 char *rvif_argv[11], 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_Bopt) {
36 *ap++ = "-B";
37 *ap++ = rvinterf_Bopt;
38 }
39 if (rvinterf_lopt) {
40 *ap++ = "-l";
41 *ap++ = rvinterf_lopt;
42 }
43 if (rvinterf_wopt) {
44 *ap++ = "-w";
45 *ap++ = rvinterf_wopt;
46 }
47 *ap++ = ttyport;
48 *ap = 0;
49 rc = vfork();
50 if (rc < 0) {
51 perror("vfork for launching rvinterf");
52 exit(1);
53 }
54 if (!rc) {
55 /* we are in the child - do the exec */
56 close(sp[0]);
57 execv(rvinterf_pathname, rvif_argv);
58 perror(rvinterf_pathname);
59 _exit(1);
60 }
61 close(sp[1]);
62 return 0;
63 }