summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c24
-rw-r--r--src/core/wee-sys.c7
-rw-r--r--src/core/wee-sys.h2
-rw-r--r--src/plugins/xfer/xfer-network.c2
4 files changed, 23 insertions, 12 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index b777f6b51..f15390afa 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -6723,6 +6723,9 @@ COMMAND_CALLBACK(set)
COMMAND_CALLBACK(sys)
{
+ long value;
+ char *error;
+
/* make C compiler happy */
(void) pointer;
(void) data;
@@ -6732,8 +6735,7 @@ COMMAND_CALLBACK(sys)
if (string_strcmp (argv[1], "get") == 0)
{
- COMMAND_MIN_ARGS(2, "get");
-
+ COMMAND_MIN_ARGS(3, "get");
if (string_strcmp (argv[2], "rlimit") == 0)
sys_display_rlimit ();
else if (string_strcmp (argv[2], "rusage") == 0)
@@ -6751,7 +6753,12 @@ COMMAND_CALLBACK(sys)
if (string_strcmp (argv[1], "waitpid") == 0)
{
- sys_waitpid ();
+ COMMAND_MIN_ARGS(3, "waitpid");
+ error = NULL;
+ value = strtol (argv[2], &error, 10);
+ if (!error || error[0])
+ COMMAND_ERROR;
+ sys_waitpid ((int)value);
return WEECHAT_RC_OK;
}
@@ -9094,9 +9101,9 @@ command_init ()
hook_command (
NULL, "sys",
N_("system actions"),
- "get rlimit|rusage"
- " || suspend"
- " || waitpid",
+ N_("get rlimit|rusage"
+ " || suspend"
+ " || waitpid <number>"),
CMD_ARGS_DESC(
N_("raw[get]: display system info"),
N_("raw[rlimit]: display resource limits "
@@ -9105,10 +9112,11 @@ command_init ()
N_("raw[suspend]: suspend WeeChat and go back to the shell, by sending "
"signal SIGTSTP to the WeeChat process") ,
N_("raw[waitpid]: acknowledge the end of children processes "
- "(to prevent \"zombie\" processes)")),
+ "(to prevent \"zombie\" processes)"),
+ N_("number: number of processes to clean")),
"get rlimit|rusage"
" || suspend"
- " || waitpid",
+ " || waitpid 1|10|100|1000",
&command_sys, NULL, NULL);
hook_command (
NULL, "toggle",
diff --git a/src/core/wee-sys.c b/src/core/wee-sys.c
index 7560b80aa..0a6fd8ec6 100644
--- a/src/core/wee-sys.c
+++ b/src/core/wee-sys.c
@@ -349,13 +349,16 @@ sys_display_rusage ()
*/
void
-sys_waitpid ()
+sys_waitpid (int number_processes)
{
int i;
+ if (number_processes < 1)
+ return;
+
/* acknowledge the end of up to 42 forked processes */
i = 0;
- while ((i < 42) && (waitpid (-1, NULL, WNOHANG) > 0))
+ while ((i < number_processes) && (waitpid (-1, NULL, WNOHANG) > 0))
{
i++;
}
diff --git a/src/core/wee-sys.h b/src/core/wee-sys.h
index eb4e7bcb9..d264d5f20 100644
--- a/src/core/wee-sys.h
+++ b/src/core/wee-sys.h
@@ -31,6 +31,6 @@ struct t_rlimit_resource
extern void sys_setrlimit ();
extern void sys_display_rlimit ();
extern void sys_display_rusage ();
-extern void sys_waitpid ();
+extern void sys_waitpid (int number_processes);
#endif /* WEECHAT_SYS_H */
diff --git a/src/plugins/xfer/xfer-network.c b/src/plugins/xfer/xfer-network.c
index 3c7b63338..9eeabf904 100644
--- a/src/plugins/xfer/xfer-network.c
+++ b/src/plugins/xfer/xfer-network.c
@@ -484,7 +484,7 @@ xfer_network_child_kill (struct t_xfer *xfer)
{
kill (xfer->child_pid, SIGKILL);
weechat_command (weechat_buffer_search_main (),
- "/mute /wait 100ms /sys waitpid");
+ "/mute /wait 100ms /sys waitpid 10");
xfer->child_pid = 0;
}