summaryrefslogtreecommitdiff
path: root/src/core/wee-command.c
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2009-03-06 18:22:34 +0100
committerSebastien Helleu <flashcode@flashtux.org>2009-03-06 18:22:34 +0100
commit8e551473641151d1e5f043ac279eca399daff5fb (patch)
tree0374c21edec94e29b550c61819bff51c1381c16f /src/core/wee-command.c
parent0fd8bbc2de94705d94b56966d681264f73b48dd2 (diff)
downloadweechat-8e551473641151d1e5f043ac279eca399daff5fb.zip
Add new hook type "process": launch command with fork and catch result (rc/stdout/stderr) via callback
Diffstat (limited to 'src/core/wee-command.c')
-rw-r--r--src/core/wee-command.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 10295959c..45734d590 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -2053,6 +2053,7 @@ command_plugin_list (const char *name, int full)
plugins_found++;
/* plugin info */
+ gui_chat_printf (NULL, "");
gui_chat_printf (NULL,
" %s%s%s v%s - %s (%s)",
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
@@ -2161,7 +2162,26 @@ command_plugin_list (const char *name, int full)
_(" exception") : "");
}
}
-
+
+ /* process hooked */
+ hook_found = 0;
+ for (ptr_hook = weechat_hooks[HOOK_TYPE_PROCESS]; ptr_hook;
+ ptr_hook = ptr_hook->next_hook)
+ {
+ if (!ptr_hook->deleted && (ptr_hook->plugin == ptr_plugin))
+ {
+ if (!hook_found)
+ gui_chat_printf (NULL,
+ _(" process hooked:"));
+ hook_found = 1;
+ gui_chat_printf (NULL,
+ _(" command: '%s', child "
+ "pid: %d"),
+ (HOOK_PROCESS(ptr_hook, command)),
+ HOOK_PROCESS(ptr_hook, child_pid));
+ }
+ }
+
/* connect hooked */
hook_found = 0;
for (ptr_hook = weechat_hooks[HOOK_TYPE_CONNECT]; ptr_hook;
@@ -2175,10 +2195,11 @@ command_plugin_list (const char *name, int full)
hook_found = 1;
gui_chat_printf (NULL,
_(" socket: %d, address: %s, "
- "port: %d"),
+ "port: %d, child pid: %d"),
HOOK_CONNECT(ptr_hook, sock),
HOOK_CONNECT(ptr_hook, address),
- HOOK_CONNECT(ptr_hook, port));
+ HOOK_CONNECT(ptr_hook, port),
+ HOOK_CONNECT(ptr_hook, child_pid));
}
}
@@ -3079,6 +3100,17 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
(void) data;
(void) buffer;
(void) argv;
+
+ /* it's forbidden to upgrade while there are some background process
+ (hook type "process" or "connect") */
+ if (weechat_hooks[HOOK_TYPE_PROCESS] || weechat_hooks[HOOK_TYPE_CONNECT])
+ {
+ gui_chat_printf (NULL,
+ _("%sCan't upgrade: there is one or more background "
+ "process (hook type 'process' or 'connect')"),
+ gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
+ return WEECHAT_RC_OK;
+ }
if (argc > 1)
{
@@ -3096,7 +3128,7 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
ptr_binary);
free (ptr_binary);
- return WEECHAT_RC_ERROR;
+ return WEECHAT_RC_OK;
}
if ((!(stat_buf.st_mode & S_IXUSR)) && (!(stat_buf.st_mode & S_IXGRP))
&& (!(stat_buf.st_mode & S_IXOTH)))
@@ -3107,7 +3139,7 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR],
ptr_binary);
free (ptr_binary);
- return WEECHAT_RC_ERROR;
+ return WEECHAT_RC_OK;
}
}
}
@@ -3119,7 +3151,7 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
gui_chat_printf (NULL,
_("%sNot enough memory"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
- return WEECHAT_RC_ERROR;
+ return WEECHAT_RC_OK;
}
gui_chat_printf (NULL,
@@ -3135,7 +3167,7 @@ command_upgrade (void *data, struct t_gui_buffer *buffer,
_("%sError: unable to save session in file"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
free (ptr_binary);
- return WEECHAT_RC_ERROR;
+ return WEECHAT_RC_OK;
}
exec_args[0] = ptr_binary;