Rename procPipe to utilPipe

master
C. McEnroe 2020-02-13 21:57:55 -05:00
parent a6bc2ea7c3
commit 1e226593ef
5 changed files with 17 additions and 17 deletions

16
chat.c
View File

@ -78,11 +78,11 @@ static void exitSave(void) {
uint32_t hashInit; uint32_t hashInit;
int procPipe[2] = { -1, -1 }; int utilPipe[2] = { -1, -1 };
static void pipeRead(void) { static void utilRead(void) {
char buf[1024]; char buf[1024];
ssize_t len = read(procPipe[0], buf, sizeof(buf) - 1); ssize_t len = read(utilPipe[0], buf, sizeof(buf) - 1);
if (len < 0) err(EX_IOERR, "read"); if (len < 0) err(EX_IOERR, "read");
if (!len) return; if (!len) return;
buf[len - 1] = '\0'; buf[len - 1] = '\0';
@ -221,17 +221,17 @@ int main(int argc, char *argv[]) {
signal(SIGCHLD, signalHandler); signal(SIGCHLD, signalHandler);
sig_t cursesWinch = signal(SIGWINCH, signalHandler); sig_t cursesWinch = signal(SIGWINCH, signalHandler);
int error = pipe(procPipe); int error = pipe(utilPipe);
if (error) err(EX_OSERR, "pipe"); if (error) err(EX_OSERR, "pipe");
fcntl(irc, F_SETFD, FD_CLOEXEC); fcntl(irc, F_SETFD, FD_CLOEXEC);
fcntl(procPipe[0], F_SETFD, FD_CLOEXEC); fcntl(utilPipe[0], F_SETFD, FD_CLOEXEC);
fcntl(procPipe[1], F_SETFD, FD_CLOEXEC); fcntl(utilPipe[1], F_SETFD, FD_CLOEXEC);
struct pollfd fds[3] = { struct pollfd fds[3] = {
{ .events = POLLIN, .fd = STDIN_FILENO }, { .events = POLLIN, .fd = STDIN_FILENO },
{ .events = POLLIN, .fd = irc }, { .events = POLLIN, .fd = irc },
{ .events = POLLIN, .fd = procPipe[0] }, { .events = POLLIN, .fd = utilPipe[0] },
}; };
while (!self.quit) { while (!self.quit) {
int nfds = poll(fds, ARRAY_LEN(fds), -1); int nfds = poll(fds, ARRAY_LEN(fds), -1);
@ -239,7 +239,7 @@ int main(int argc, char *argv[]) {
if (nfds > 0) { if (nfds > 0) {
if (fds[0].revents) uiRead(); if (fds[0].revents) uiRead();
if (fds[1].revents) ircRecv(); if (fds[1].revents) ircRecv();
if (fds[2].revents) pipeRead(); if (fds[2].revents) utilRead();
} }
if (signals[SIGHUP]) self.quit = "zzz"; if (signals[SIGHUP]) self.quit = "zzz";

4
chat.h
View File

@ -28,8 +28,6 @@
typedef unsigned char byte; typedef unsigned char byte;
int procPipe[2];
enum Color { enum Color {
White, Black, Blue, Green, Red, Brown, Magenta, Orange, White, Black, Blue, Green, Red, Brown, Magenta, Orange,
Yellow, LightGreen, Cyan, LightCyan, LightBlue, Pink, Gray, LightGray, Yellow, LightGreen, Cyan, LightCyan, LightBlue, Pink, Gray, LightGray,
@ -147,6 +145,8 @@ const char *commandIsNotice(size_t id, const char *input);
const char *commandIsAction(size_t id, const char *input); const char *commandIsAction(size_t id, const char *input);
void commandComplete(void); void commandComplete(void);
int utilPipe[2];
enum { UtilCap = 16 }; enum { UtilCap = 16 };
struct Util { struct Util {
size_t argc; size_t argc;

View File

@ -207,7 +207,7 @@ static void commandHelp(size_t id, char *params) {
snprintf(buf, sizeof(buf), "ip%s$", (params ? params : "COMMANDS")); snprintf(buf, sizeof(buf), "ip%s$", (params ? params : "COMMANDS"));
setenv("LESS", buf, 1); setenv("LESS", buf, 1);
execlp("man", "man", "1", "catgirl", NULL); execlp("man", "man", "1", "catgirl", NULL);
dup2(procPipe[1], STDERR_FILENO); dup2(utilPipe[1], STDERR_FILENO);
warn("man"); warn("man");
_exit(EX_UNAVAILABLE); _exit(EX_UNAVAILABLE);
} }

4
ui.c
View File

@ -572,8 +572,8 @@ static void notify(size_t id, const char *str) {
if (pid) return; if (pid) return;
close(STDIN_FILENO); close(STDIN_FILENO);
dup2(procPipe[1], STDOUT_FILENO); dup2(utilPipe[1], STDOUT_FILENO);
dup2(procPipe[1], STDERR_FILENO); dup2(utilPipe[1], STDERR_FILENO);
execvp(util.argv[0], (char *const *)util.argv); execvp(util.argv[0], (char *const *)util.argv);
warn("%s", util.argv[0]); warn("%s", util.argv[0]);
_exit(EX_CONFIG); _exit(EX_CONFIG);

8
url.c
View File

@ -107,8 +107,8 @@ static void urlOpen(const char *url) {
if (pid) return; if (pid) return;
close(STDIN_FILENO); close(STDIN_FILENO);
dup2(procPipe[1], STDOUT_FILENO); dup2(utilPipe[1], STDOUT_FILENO);
dup2(procPipe[1], STDERR_FILENO); dup2(utilPipe[1], STDERR_FILENO);
if (urlOpenUtil.argc) { if (urlOpenUtil.argc) {
struct Util util = urlOpenUtil; struct Util util = urlOpenUtil;
utilPush(&util, url); utilPush(&util, url);
@ -156,8 +156,8 @@ static void urlCopy(const char *url) {
} }
dup2(rw[0], STDIN_FILENO); dup2(rw[0], STDIN_FILENO);
dup2(procPipe[1], STDOUT_FILENO); dup2(utilPipe[1], STDOUT_FILENO);
dup2(procPipe[1], STDERR_FILENO); dup2(utilPipe[1], STDERR_FILENO);
close(rw[0]); close(rw[0]);
if (urlCopyUtil.argc) { if (urlCopyUtil.argc) {
execvp(urlCopyUtil.argv[0], (char *const *)urlCopyUtil.argv); execvp(urlCopyUtil.argv[0], (char *const *)urlCopyUtil.argv);