aboutsummaryrefslogtreecommitdiffstats
path: root/src/hooks.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hooks.c')
-rw-r--r--src/hooks.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/hooks.c b/src/hooks.c
index b4933af..f649076 100644
--- a/src/hooks.c
+++ b/src/hooks.c
@@ -1,7 +1,7 @@
/*
* Calcurse - text-based organizer
*
- * Copyright (c) 2004-2020 calcurse Development Team <misc@calcurse.org>
+ * Copyright (c) 2004-2023 calcurse Development Team <misc@calcurse.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,20 +41,18 @@
int run_hook(const char *name)
{
- char *hook_path = NULL, *hook_cmd = NULL, *mesg;
+ char *hook_path = NULL, *mesg;
+ int pid, pin, pout, perr, ret = -127;
char const *arg[2];
- int pid, ret = -127;
asprintf(&hook_path, "%s/%s", path_hooks, name);
if (!io_file_exists(hook_path))
goto cleanup;
-
- asprintf(&hook_cmd, "%s <&- >&- 2>&-", hook_path);
- arg[0] = hook_cmd;
+ arg[0] = hook_path;
arg[1] = NULL;
- if ((pid = shell_exec(NULL, NULL, *arg, arg))) {
- ret = child_wait(NULL, NULL, pid);
+ if ((pid = shell_exec(&pin, &pout, &perr, 1, *arg, arg))) {
+ ret = child_wait(&pin, &pout, &perr, pid);
if (ret > 0 && WIFEXITED(ret)) {
asprintf(&mesg, "%s hook: exit status %d",
name,
@@ -71,6 +69,5 @@ int run_hook(const char *name)
cleanup:
mem_free(hook_path);
- mem_free(hook_cmd);
return ret;
}