Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-projects commit in portage-utils/libq: xsystem.c
Date: Mon, 21 Feb 2011 22:03:09
Message-Id: 20110221220259.35ADB20057@flycatcher.gentoo.org
1 vapier 11/02/21 22:02:59
2
3 Modified: xsystem.c
4 Log:
5 add support for CONFIG_PROTECT_MASK when unmerging, as well as running the pkg_{pre,post}rm funcs
6
7 Revision Changes Path
8 1.2 portage-utils/libq/xsystem.c
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xsystem.c?rev=1.2&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xsystem.c?rev=1.2&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/portage-utils/libq/xsystem.c?r1=1.1&r2=1.2
13
14 Index: xsystem.c
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-projects/portage-utils/libq/xsystem.c,v
17 retrieving revision 1.1
18 retrieving revision 1.2
19 diff -u -r1.1 -r1.2
20 --- xsystem.c 13 Jan 2010 19:15:17 -0000 1.1
21 +++ xsystem.c 21 Feb 2011 22:02:59 -0000 1.2
22 @@ -3,14 +3,36 @@
23 *
24 * Copyright 2005-2010 Gentoo Foundation
25 * Distributed under the terms of the GNU General Public License v2
26 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/xsystem.c,v 1.1 2010/01/13 19:15:17 vapier Exp $
27 + * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/xsystem.c,v 1.2 2011/02/21 22:02:59 vapier Exp $
28 */
29
30 #include <stdlib.h>
31 +#include <sys/wait.h>
32
33 -void xsystem(const char *command);
34 -void xsystem(const char *command)
35 +static void xsystem(const char *command)
36 {
37 if (system(command))
38 errp("system(%s) failed", command);
39 }
40 +
41 +static void xsystembash(const char *command)
42 +{
43 + pid_t p = vfork();
44 + int status;
45 +
46 + switch (p) {
47 + case 0: /* child */
48 + execl("/bin/bash", "bash", "--norc", "--noprofile", "-c", command, NULL);
49 + /* Hrm, still here ? Maybe no bash ... */
50 + _exit(execl("/bin/sh", "sh", "-c", command, NULL));
51 +
52 + default: /* parent */
53 + waitpid(p, &status, 0);
54 + if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
55 + return;
56 + /* fall through */
57 +
58 + case -1: /* fucked */
59 + errp("xsystembash(%s) failed", command);
60 + }
61 +}