|
@@ -19,6 +19,7 @@
|
|
|
#include <sys/types.h>
|
|
|
#include <sys/stat.h>
|
|
|
#include <fcntl.h>
|
|
|
+#include <limits.h>
|
|
|
|
|
|
/*--------------------------------------------------------- */
|
|
|
CLISH_PLUGIN_SYM(clish_script)
|
|
@@ -28,7 +29,7 @@ CLISH_PLUGIN_SYM(clish_script)
|
|
|
const char *shebang = NULL;
|
|
|
pid_t cpid = -1;
|
|
|
int res;
|
|
|
- const char *fifo_name;
|
|
|
+ char fifo_name[PATH_MAX];
|
|
|
FILE *rpipe, *wpipe;
|
|
|
char *command = NULL;
|
|
|
|
|
@@ -55,8 +56,7 @@ CLISH_PLUGIN_SYM(clish_script)
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
/* Get FIFO */
|
|
|
- fifo_name = clish_shell__get_fifo(this);
|
|
|
- if (!fifo_name) {
|
|
|
+ if (! clish_shell_mkfifo(this, fifo_name, sizeof(fifo_name))) {
|
|
|
fprintf(stderr, "Error: Can't create temporary FIFO.\n"
|
|
|
"Error: The ACTION will be not executed.\n");
|
|
|
return -1;
|
|
@@ -67,6 +67,7 @@ CLISH_PLUGIN_SYM(clish_script)
|
|
|
if (cpid == -1) {
|
|
|
fprintf(stderr, "Error: Can't fork the write process.\n"
|
|
|
"Error: The ACTION will be not executed.\n");
|
|
|
+ clish_shell_rmfifo(this, fifo_name);
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
@@ -103,7 +104,6 @@ CLISH_PLUGIN_SYM(clish_script)
|
|
|
if (!rpipe) {
|
|
|
fprintf(stderr, "Error: Can't fork the script.\n"
|
|
|
"Error: The ACTION will be not executed.\n");
|
|
|
- lub_string_free(command);
|
|
|
kill(cpid, SIGTERM);
|
|
|
waitpid(cpid, NULL, 0);
|
|
|
|
|
@@ -111,6 +111,8 @@ CLISH_PLUGIN_SYM(clish_script)
|
|
|
sigaction(SIGINT, &sig_old_int, NULL);
|
|
|
sigaction(SIGQUIT, &sig_old_quit, NULL);
|
|
|
|
|
|
+ lub_string_free(command);
|
|
|
+ clish_shell_rmfifo(this, fifo_name);
|
|
|
return -1;
|
|
|
}
|
|
|
/* Read the result of script execution */
|
|
@@ -133,7 +135,10 @@ CLISH_PLUGIN_SYM(clish_script)
|
|
|
kill(cpid, SIGTERM);
|
|
|
waitpid(cpid, NULL, 0);
|
|
|
}
|
|
|
+
|
|
|
+ /* Clean up */
|
|
|
lub_string_free(command);
|
|
|
+ clish_shell_rmfifo(this, fifo_name);
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
fprintf(stderr, "RETCODE: %d\n", WEXITSTATUS(res));
|