FreeCalypso > hg > freecalypso-tools
comparison rvinterf/rvtat/launchrvif.c @ 346:99471c57155a
fcup-rvtat program written, compiles
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 04 Feb 2018 16:45:05 +0000 |
| parents | rvinterf/etmsync/launchrvif.c@3fb0c7ad27f3 |
| children |
comparison
equal
deleted
inserted
replaced
| 345:cc207d81c05f | 346:99471c57155a |
|---|---|
| 1 /* | |
| 2 * This module implements the optional "behind the scenes" invokation | |
| 3 * of rvinterf from fc-fsio etc. | |
| 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 #include "exitcodes.h" | |
| 12 | |
| 13 static char rvinterf_pathname[] = "/opt/freecalypso/bin/rvinterf"; | |
| 14 | |
| 15 extern int sock; | |
| 16 | |
| 17 char *rvinterf_ttyport, *rvinterf_Bopt, *rvinterf_lopt, *rvinterf_wopt; | |
| 18 | |
| 19 launch_rvinterf() | |
| 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(ERROR_UNIX); | |
| 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++ = rvinterf_ttyport; | |
| 48 *ap = 0; | |
| 49 rc = vfork(); | |
| 50 if (rc < 0) { | |
| 51 perror("vfork for launching rvinterf"); | |
| 52 exit(ERROR_UNIX); | |
| 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 } |
