aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-03 09:59:07 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-08-03 09:59:07 +0000
commit259781cdc07743cd510bb312f97edef77fe5aa5d (patch)
treeb58f2704d2efc8409ed5165f2869a872e6525b3c
parent03312ea3156e88eeffabd86ae4c02462ed2a8d7a (diff)
utils.c: replaced fork() + exec() with GSpawn.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@459 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.ja6
-rw-r--r--src/utils.c54
3 files changed, 25 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 962bb9c1..3eff3ed0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-08-03
+
+ * src/utils.c:
+ execute_async()
+ execute_sync(): replaced fork() + exec() with GSpawn.
+
2005-08-02
* src/compose.c
diff --git a/ChangeLog.ja b/ChangeLog.ja
index a9c15472..757bc7e7 100644
--- a/ChangeLog.ja
+++ b/ChangeLog.ja
@@ -1,3 +1,9 @@
+2005-08-03
+
+ * src/utils.c:
+ execute_async()
+ execute_sync(): fork() + exec() を GSpawn で置き換えた。
+
2005-08-02
* src/compose.c
diff --git a/src/utils.c b/src/utils.c
index 56c60c0f..6463698a 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -2900,59 +2900,29 @@ gchar *file_read_stream_to_str(FILE *fp)
gint execute_async(gchar *const argv[])
{
- pid_t pid;
- gint status;
+ g_return_val_if_fail(argv != NULL && argv[0] != NULL, -1);
- if ((pid = fork()) < 0) {
- perror("fork");
+ if (g_spawn_async(NULL, (gchar **)argv, NULL, G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL, FALSE) == FALSE) {
+ g_warning("Can't execute command: %s\n", argv[0]);
return -1;
}
- if (pid == 0) { /* child process */
- pid_t gch_pid;
-
- if ((gch_pid = fork()) < 0) {
- perror("fork");
- _exit(1);
- }
-
- if (gch_pid == 0) { /* grandchild process */
- execvp(argv[0], argv);
-
- perror("execvp");
- _exit(1);
- }
-
- _exit(0);
- }
-
- waitpid(pid, &status, 0);
-
- if (WIFEXITED(status))
- return WEXITSTATUS(status);
- else
- return -1;
+ return 0;
}
gint execute_sync(gchar *const argv[])
{
- pid_t pid;
gint status;
- if ((pid = fork()) < 0) {
- perror("fork");
- return -1;
- }
-
- if (pid == 0) { /* child process */
- execvp(argv[0], argv);
+ g_return_val_if_fail(argv != NULL && argv[0] != NULL, -1);
- perror("execvp");
- _exit(1);
+ if (g_spawn_sync(NULL, (gchar **)argv, NULL, G_SPAWN_SEARCH_PATH,
+ NULL, NULL, NULL, NULL, &status, NULL) == FALSE) {
+ g_warning("Can't execute command: %s\n", argv[0]);
+ return -1;
}
- waitpid(pid, &status, 0);
-
if (WIFEXITED(status))
return WEXITSTATUS(status);
else
@@ -2964,7 +2934,7 @@ gint execute_command_line(const gchar *cmdline, gboolean async)
gchar **argv;
gint ret;
- debug_print("executing: %s\n", cmdline);
+ debug_print("execute_command_line(): executing: %s\n", cmdline);
argv = strsplit_with_quote(cmdline, " ", 0);
@@ -2985,6 +2955,8 @@ gchar *get_command_output(const gchar *cmdline)
g_return_val_if_fail(cmdline != NULL, NULL);
+ debug_print("get_command_output(): executing: %s\n", cmdline);
+
if (g_spawn_command_line_sync(cmdline, &child_stdout, NULL, &status,
NULL) == FALSE) {
g_warning("Can't execute command: %s\n", cmdline);