[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[packagekit] Re: RFH: Port packagekit to !linux



Package: packagekit
Version: 0.8.7-1
Severity: important
Tags: patch
User: debian-bsd@lists.debian.org
Usertags: kfreebsd


On Thu, 18 Apr 2013, Matthias Klumpp wrote:
PackageKit in it's newest version doesn't build on !linux
architectures, due to Linux specific functions, and I don't have the
knowledge to make it work on !linux.

There are two problematic parts.

The first one is a try to auto-kill a spawned agent process,
when the master process suddenly dies. In normal case,
it is signaled from master.
There is no counter part functionality on (k)FreeBSD.

The second one is wait for agent process finish.
The packagekit code uses unnecessary complex function to achieve it.
The simple waitpid() suffices everywhere.

The patch is attached.

Petr
--- packagekit-0.8.7.orig/lib/packagekit-glib2/pk-spawn-polkit-agent.c
+++ packagekit-0.8.7/lib/packagekit-glib2/pk-spawn-polkit-agent.c
@@ -21,7 +21,9 @@
 
 #include <stdio.h>
 #include <sys/types.h>
+#ifdef __linux__
 #include <sys/prctl.h>
+#endif
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
@@ -68,13 +70,14 @@ fork_agent (pid_t *pid, const char *path
 		*pid = n_agent_pid;
 		return 0;
 	}
+#ifdef __linux__
 
 	/* In the child:
 	 *
 	 * Make sure the agent goes away when the parent dies */
 	if (prctl (PR_SET_PDEATHSIG, SIGTERM) < 0)
 		_exit (EXIT_FAILURE);
-
+#endif
 	/* Check whether our parent died before we were able
 	 * to set the death signal */
 	if (getppid () != parent_pid)
@@ -175,22 +178,16 @@ fd_wait_for_event (int fd, int event, ui
 }
 
 static int
-wait_for_terminate (pid_t pid, siginfo_t *status) {
-	siginfo_t dummy;
-
+wait_for_terminate (pid_t pid) {
+        int status;
 	g_assert (pid >= 1);
 
-	if (!status)
-		status = &dummy;
-
 	for (;;) {
-		zero(*status);
-		if (waitid(P_PID, pid, status, WEXITED) < 0) {
+		if (waitpid(pid, &status, 0) < 0) {
 			if (errno == EINTR)
 				continue;
 			return -errno;
 		}
-
 		return 0;
 	}
 }
@@ -242,6 +239,6 @@ pk_polkit_agent_close (void) {
 	/* Inform agent that we are done */
 	kill (agent_pid, SIGTERM);
 	kill (agent_pid, SIGCONT);
-	wait_for_terminate (agent_pid, NULL);
+	wait_for_terminate (agent_pid);
 	agent_pid = 0;
 }

Reply to: