aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-09-06 03:52:18 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-09-06 03:52:18 +0000
commit8c2d2cd97b2b52fea68fa2913a129560661ccbc2 (patch)
treee7bffb6fac675c511951638c25ea0a685e17ee11
parentd4c112e8df73070a3c1e4e3e7d4a6a6cacc879e4 (diff)
socket.c: retry waitpid() when it is interrupted.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1143 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog5
-rw-r--r--ChangeLog.ja5
-rw-r--r--libsylph/socket.c26
3 files changed, 30 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 935a8b5e..202d142a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2006-09-06
+ * libsylph/socket.c: retry waitpid() when it is interrupted
+ (thanks to Stefaan).
+
+2006-09-06
+
* src/action.c: free_children(): wait for processes when they still
exist.
Kill/wait child pid instead of pgid (thanks to Stefaan A Eeckels).
diff --git a/ChangeLog.ja b/ChangeLog.ja
index aaa62a1d..cc687cd5 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,5 +1,10 @@
2006-09-06
+ * libsylph/socket.c: waitpid() が割り込まれた場合は再試行するように
+ した(Stefaan さん thanks)。
+
+2006-09-06
+
* src/action.c: free_children(): プロセスが残っている場合は wait
するようにした。
pgid でなく pid を kill/wait するようにした(Stefaan A Eeckels さん
diff --git a/libsylph/socket.c b/libsylph/socket.c
index 7ddde9e5..7b67d8fb 100644
--- a/libsylph/socket.c
+++ b/libsylph/socket.c
@@ -941,6 +941,23 @@ static gint sock_connect_address_list_async(SockConnectData *conn_data)
return 0;
}
+static gint sock_kill_process(pid_t pid)
+{
+ pid_t ret = (pid_t)-1;
+
+ kill(pid, SIGKILL);
+
+ while (ret == (pid_t)-1) {
+ if ((ret = waitpid(pid, NULL, 0)) != pid) {
+ perror("sock_kill_process(): waitpid");
+ if (ret == (pid_t)-1 && errno != EINTR)
+ break;
+ }
+ }
+
+ return (gint)pid;
+}
+
/* asynchronous DNS lookup */
static gboolean sock_get_address_info_async_cb(GIOChannel *source,
@@ -1001,8 +1018,7 @@ static gboolean sock_get_address_info_async_cb(GIOChannel *source,
g_io_channel_shutdown(source, FALSE, NULL);
g_io_channel_unref(source);
- kill(lookup_data->child_pid, SIGKILL);
- waitpid(lookup_data->child_pid, NULL, 0);
+ sock_kill_process(lookup_data->child_pid);
lookup_data->func(addr_list, lookup_data->data);
@@ -1138,10 +1154,8 @@ static gint sock_get_address_info_async_cancel(SockLookupData *lookup_data)
g_io_channel_unref(lookup_data->channel);
}
- if (lookup_data->child_pid > 0) {
- kill(lookup_data->child_pid, SIGKILL);
- waitpid(lookup_data->child_pid, NULL, 0);
- }
+ if (lookup_data->child_pid > 0)
+ sock_kill_process(lookup_data->child_pid);
g_free(lookup_data->hostname);
g_free(lookup_data);