version 1.35, 2015/03/19 21:22:15 |
version 1.36, 2016/09/08 07:50:09 |
|
|
#include <sys/queue.h> |
#include <sys/queue.h> |
#include <sys/socket.h> |
#include <sys/socket.h> |
#include <sys/types.h> |
#include <sys/types.h> |
|
#include <sys/wait.h> |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <poll.h> |
#include <poll.h> |
|
|
pipeio(const char* const path, char* const argv[], char* const text, int len, |
pipeio(const char* const path, char* const argv[], char* const text, int len, |
struct buffer *outbp) |
struct buffer *outbp) |
{ |
{ |
int s[2]; |
int s[2], ret; |
char *err; |
char *err; |
|
pid_t pid; |
|
|
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, s) == -1) { |
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, s) == -1) { |
dobeep(); |
dobeep(); |
|
|
return (FALSE); |
return (FALSE); |
} |
} |
|
|
switch(fork()) { |
switch((pid = fork())) { |
case -1: |
case -1: |
dobeep(); |
dobeep(); |
ewprintf("Can't fork"); |
ewprintf("Can't fork"); |
|
|
default: |
default: |
/* Parent process */ |
/* Parent process */ |
close(s[1]); |
close(s[1]); |
return (iomux(s[0], text, len, outbp)); |
ret = iomux(s[0], text, len, outbp); |
|
waitpid(pid, NULL, 0); /* Collect child to prevent zombies */ |
|
|
|
return (ret); |
} |
} |
return (FALSE); |
return (FALSE); |
} |
} |