14static void die_usage()
16 logmsg(
WHO,100,USAGE,
"preline cmd [ arg ... ]");
28int main(
int argc,
char *
const *argv)
37 if (!(
ufline = env_get(
"UFLINE"))) die_usage();
38 if (!(
rpline = env_get(
"RPLINE"))) die_usage();
39 if (!(
dtline = env_get(
"DTLINE"))) die_usage();
41 while ((opt = getoptb(argc,(
char **)argv,
"frdFRD")) != opteof)
53 if (!*argv) die_usage();
56 logmsg(
WHO,111,FATAL,
"unable to create pipe");
60 logmsg(
WHO,111,FATAL,
"unable to fork");
64 if (fd_move(0,pi[0]) == -1)
65 logmsg(
WHO,111,FATAL,
"unable to set up fds");
68 logmsg(
WHO,errno,FATAL,B(
"unable to run: ",*argv));
71 if (fd_move(1,pi[1]) == -1)
72 logmsg(
WHO,111,FATAL,
"unable to set up fds");
77 if (buffer_copy(&
bo,&
bi) != 0)
78 logmsg(
WHO,111,FATAL,
"unable to copy input");
82 if (wait_pid(&wstat,pid) == -1)
83 logmsg(
WHO,111,FATAL,
"wait failed");
84 if (wait_crashed(wstat))
85 logmsg(
WHO,111,FATAL,
"child crashed");
86 _exit(wait_exitcode(wstat));
char outbuf[BUFSIZE_LINE]