commit e96335b4155a2bac0e9e2c1ac53ec8735730cbe7
parent 0d996ecff96585f20aefe1c264b87b4d3b8ae865
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Fri, 7 Aug 2020 14:18:41 +0200
change plumb() to a bit more generic forkexec()
Allowing easier modification to pass more than one argument to the executed
program.
+ Some pedantic fixes checking for -1 instead of < 0.
Diffstat:
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/README b/README
@@ -137,13 +137,13 @@ reload the feeds by sending the signal SIGHUP.
In the input handling code you can then add a case:
case 'M':
- plumb("markallread.sh", NULL);
+ forkexec((char *[]) { "markallread.sh", NULL });
break;
or
case 'S':
- plumb("syncnews.sh", NULL);
+ forkexec((char *[]) { "syncnews.sh", NULL });
break;
The specified script should be in $PATH or an absolute path.
diff --git a/sfeed_curses.c b/sfeed_curses.c
@@ -589,7 +589,7 @@ pipeitem(const char *cmd, struct item *item, int wantoutput)
}
void
-plumb(const char *cmd, char *url)
+forkexec(char *argv[])
{
switch (fork()) {
case -1:
@@ -597,7 +597,7 @@ plumb(const char *cmd, char *url)
case 0:
dup2(devnullfd, 1);
dup2(devnullfd, 2);
- if (execlp(cmd, cmd, url, NULL) < 0)
+ if (execvp(argv[0], argv) == -1)
_exit(1);
}
}
@@ -1437,7 +1437,7 @@ mousereport(int button, int release, int x, int y)
row = pane_row_get(p, p->pos);
item = (struct item *)row->data;
markread(p, p->pos, p->pos, 1);
- plumb(plumber, item->fields[FieldLink]);
+ forkexec((char *[]) { plumber, item->fields[FieldLink], NULL });
}
}
break;
@@ -1732,7 +1732,7 @@ main(int argc, char *argv[])
selpane = PaneItems;
}
- if ((devnullfd = open("/dev/null", O_WRONLY)) < 0)
+ if ((devnullfd = open("/dev/null", O_WRONLY)) == -1)
err(1, "open: /dev/null");
updatesidebar(onlynew);
@@ -1892,7 +1892,7 @@ nextpage:
p = &panes[selpane];
row = pane_row_get(p, p->pos);
item = (struct item *)row->data;
- plumb(plumber, item->fields[FieldEnclosure]);
+ forkexec((char *[]) { plumber, item->fields[FieldEnclosure], NULL });
}
break;
case 'm': /* toggle mouse mode */
@@ -1927,7 +1927,7 @@ nextpage:
row = pane_row_get(p, p->pos);
item = (struct item *)row->data;
markread(p, p->pos, p->pos, 1);
- plumb(plumber, item->fields[FieldLink]);
+ forkexec((char *[]) { plumber, item->fields[FieldLink], NULL });
}
break;
case 'c': /* items: pipe TSV line to program */