mirror of
https://github.com/jarun/nnn.git
synced 2024-12-01 02:49:44 +00:00
Wait for child on plugin invocation
This commit is contained in:
parent
907616a058
commit
56d3f2d976
|
@ -4785,6 +4785,8 @@ static void readpipe(int fd, char **path, char **lastname, char **lastdir)
|
||||||
|
|
||||||
static bool run_selected_plugin(char **path, const char *file, char *runfile, char **lastname, char **lastdir)
|
static bool run_selected_plugin(char **path, const char *file, char *runfile, char **lastname, char **lastdir)
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
|
pid_t p;
|
||||||
bool cmd_as_plugin = FALSE;
|
bool cmd_as_plugin = FALSE;
|
||||||
uchar_t flags = 0;
|
uchar_t flags = 0;
|
||||||
|
|
||||||
|
@ -4821,7 +4823,7 @@ static bool run_selected_plugin(char **path, const char *file, char *runfile, ch
|
||||||
|
|
||||||
exitcurses();
|
exitcurses();
|
||||||
|
|
||||||
if (fork() == 0) { // In child
|
if ((p = fork()) == 0) { // In child
|
||||||
int wfd = open(g_pipepath, O_WRONLY | O_CLOEXEC);
|
int wfd = open(g_pipepath, O_WRONLY | O_CLOEXEC);
|
||||||
|
|
||||||
if (wfd == -1)
|
if (wfd == -1)
|
||||||
|
@ -4852,6 +4854,9 @@ static bool run_selected_plugin(char **path, const char *file, char *runfile, ch
|
||||||
readpipe(rfd, path, lastname, lastdir);
|
readpipe(rfd, path, lastname, lastdir);
|
||||||
close(rfd);
|
close(rfd);
|
||||||
|
|
||||||
|
/* wait for the child to finish. no zombies allowed */
|
||||||
|
waitpid(p, &status, 0);
|
||||||
|
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
unlink(g_pipepath);
|
unlink(g_pipepath);
|
||||||
|
|
Loading…
Reference in a new issue