- UnmountEjectOp *data;
- GPid child_pid;
- GError *error;
-
- data = g_new0 (UnmountEjectOp, 1);
- data->unix_mount = unix_mount;
- 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)) {
- 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);
- g_error_free (error);
- g_free (data);
- return;
- }
- data->error_string = g_string_new ("");
- data->error_channel = g_io_channel_unix_new (data->error_fd);
- data->error_channel_source_id = g_io_add_watch (data->error_channel, G_IO_IN, eject_unmount_read_error, data);
- g_child_watch_add (child_pid, eject_unmount_cb, data);
+ GTask *task;
+ GSource *timeout;
+
+ task = g_task_new (mount, cancellable, callback, user_data);
+ g_task_set_task_data (task, g_strdupv (argv), (GDestroyNotify) g_strfreev);
+
+ if (unix_mount->volume_monitor != NULL)
+ g_signal_emit_by_name (unix_mount->volume_monitor, "mount-pre-unmount", mount);
+
+ g_signal_emit_by_name (mount, "pre-unmount", 0);
+
+ timeout = g_timeout_source_new (500);
+ g_task_attach_source (task, timeout, (GSourceFunc) eject_unmount_do_cb);
+ g_source_unref (timeout);