- ptrace(PTRACE_CONT, browserd_pid, NULL, NULL);
- while ((waited_pid = wait(&status)) > 0) {
- if (waited_pid != browserd_pid)
- /* Not interested in other processes */
- continue;
- if (WIFEXITED(status) || WIFSIGNALED(status))
- /* browserd exited */
- break;
- else if (WIFSTOPPED(status)) {
- /* browserd was sent a signal
- We're responsible for making sure this
- signal gets delivered */
- if (ignore_sigstop &&
- WSTOPSIG(status) == SIGSTOP) {
- /* Ignore the first SIGSTOP received
- This is raised for some reason
- immediately after we start tracing
- the process, and won't be followed
- by a SIGCONT at any point */
- printf("Ignoring first SIGSTOP\n");
- ptrace(PTRACE_CONT, browserd_pid,
- NULL, NULL);
- ignore_sigstop = 0;
- continue;
- }
- printf("Forwarding signal %d to browserd\n",
- WSTOPSIG(status));
- ptrace(PTRACE_CONT, browserd_pid,
- NULL, WSTOPSIG(status));
- }
- }
-
- /* Kill off browser UI
- XXX: There is a race here with the restarting of the closed
- browserd; if that happens before we kill the browser UI, the
- newly started browserd may not close with the UI
- XXX: Hope we don't cause data loss here! */
- printf("Killing MicroB\n");
- kill(pid, SIGTERM);
- waitpid(pid, &status, 0);
+ while (!kill_microb &&
+ dbus_connection_read_write_dispatch(raw_connection,
+ -1));
+ dbus_connection_remove_filter(raw_connection,
+ filter_func, NULL);
+ dbus_bus_remove_match(raw_connection,
+ "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='Mozilla.MicroB'",
+ &dbus_error);
+ if (dbus_error_is_set(&dbus_error))
+ /* Don't really care -- about to disconnect from the
+ bus anyhow */
+ dbus_error_free(&dbus_error);
+ dbus_bus_remove_match(raw_connection,
+ "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='com.nokia.microb-engine'",
+ &dbus_error);
+ if (dbus_error_is_set(&dbus_error))
+ dbus_error_free(&dbus_error);
+ dbus_connection_close(raw_connection);
+ dbus_connection_unref(raw_connection);