[Superkb-devel] [PATCH] Change system() to execvp() for command execution.
Status: Alpha
Brought to you by:
alvarezp
From: Eduardo A. B. L. <ebu...@du...> - 2010-12-11 04:55:58
|
The system() call disables the calling process until the command is executed. This behavior generated a superkb child process for each command executed. With execvp(), the child process is replaced with the user's command. --- main.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 11f4dc6..6951c4f 100755 --- a/main.c +++ b/main.c @@ -279,6 +279,7 @@ int kbwin_init(Display * dpy) void __Superkb_Action(KeyCode keycode, unsigned int state) { unsigned int i; + char *argv[4] = { "sh", "-c", NULL, NULL }; for (i = 0; i < config->key_bindings_n; i++) { if (config->key_bindings[i].keycode == keycode && config->key_bindings[i].state == state) { @@ -295,8 +296,9 @@ void __Superkb_Action(KeyCode keycode, unsigned int state) system(cmdline); } } - system(config->key_bindings[i].action.command); - exit(EXIT_SUCCESS); + argv[2] = config->key_bindings[i].action.command; + execvp(*argv, argv); + exit(EXIT_FAILURE); } break; case AT_DOCUMENT: @@ -316,9 +318,10 @@ void __Superkb_Action(KeyCode keycode, unsigned int state) strcpy (cmdline, config->document_handler); strcat (cmdline, " "); strcat (cmdline, config->key_bindings[i].action.document); - system(cmdline); + argv[2] = cmdline; + execvp(*argv, argv); } - exit(EXIT_SUCCESS); + exit(EXIT_FAILURE); } break; case AT_FUNCTION: -- 1.7.2.3 |