-static void
-eject_mount_do (GVolume *volume,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data,
- char **argv)
-{
- GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
- EjectMountOp *data;
- GPid child_pid;
- GSource *child_watch;
- GError *error;
-
- data = g_new0 (EjectMountOp, 1);
- data->unix_volume = unix_volume;
- data->callback = callback;
- data->user_data = user_data;
- data->cancellable = cancellable;
-
- error = NULL;
- if (!g_spawn_async_with_pipes (NULL, /* working dir */
- 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_mount_read_error, data, NULL);
- g_source_attach (data->error_channel_source, NULL);
-
- child_watch = g_child_watch_source_new (child_pid);
- g_source_set_callback (child_watch, (GSourceFunc) eject_mount_cb, data, NULL);
- g_source_attach (child_watch, NULL);
- g_source_unref (child_watch);
-
-handle_error:
- if (error != NULL) {
- GSimpleAsyncResult *simple;
- simple = g_simple_async_result_new_from_error (G_OBJECT (data->unix_volume),
- 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_error_free (error);
- g_free (data);
- }