- if (!g_spawn_async_with_pipes (NULL, /* working dir */
- data->argv,
- NULL, /* envp */
- G_SPAWN_DO_NOT_REAP_CHILD|G_SPAWN_SEARCH_PATH,
- NULL, /* child_setup */
- NULL, /* user_data for child_setup */
- &child_pid,
- NULL, /* standard_input */
- NULL, /* standard_output */
- &(data->error_fd),
- &error)) {
- g_assert (error != NULL);
- goto handle_error;
- }
-
- data->error_string = g_string_new ("");
-
- data->error_channel = g_io_channel_unix_new (data->error_fd);
- g_io_channel_set_flags (data->error_channel, G_IO_FLAG_NONBLOCK, &error);
- if (error != NULL)
- goto handle_error;
-
- data->error_channel_source = g_io_create_watch (data->error_channel, G_IO_IN);
- g_source_set_callback (data->error_channel_source,
- (GSourceFunc) eject_unmount_read_error, data, NULL);
- g_source_attach (data->error_channel_source, g_main_context_get_thread_default ());
-
- child_watch = g_child_watch_source_new (child_pid);
- g_source_set_callback (child_watch, (GSourceFunc) eject_unmount_cb, data, NULL);
- g_source_attach (child_watch, g_main_context_get_thread_default ());
- g_source_unref (child_watch);
-
-handle_error:
- if (error != NULL) {
- GSimpleAsyncResult *simple;
- simple = g_simple_async_result_new_from_error (G_OBJECT (data->unix_mount),
- data->callback,
- data->user_data,
- error);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
-
- if (data->error_string != NULL)
- g_string_free (data->error_string, TRUE);
-
- if (data->error_channel != NULL)
- g_io_channel_unref (data->error_channel);
-
- g_strfreev (data->argv);
- g_error_free (error);
- g_free (data);
- }
-
- return FALSE;