FreeCalypso > hg > freecalypso-sw
comparison rvinterf/libasync/launchrvif.c @ 335:40b8557b9d04
rvinterf suite: libasync factored out of fc-tmsh
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 22 Apr 2014 06:51:09 +0000 |
parents | rvinterf/tmsh/launchrvif.c@c146f38d2b5f |
children |
comparison
equal
deleted
inserted
replaced
334:73a2b359b3cd | 335:40b8557b9d04 |
---|---|
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 } |