aboutsummaryrefslogtreecommitdiff
path: root/libsylph
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 /libsylph
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
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/socket.c26
1 files changed, 20 insertions, 6 deletions
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);