aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/sigchain.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2015-12-15 09:39:39 -0600
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-12-17 14:27:14 -0300
commit4b6ab94eabe4f55371cff4569750bb3996c55db6 (patch)
treedb5b95ed4647e3455bb1b1d4bb24137708a97829 /tools/perf/util/sigchain.c
parentperf tools: Finalize subcmd independence (diff)
downloadlinux-dev-4b6ab94eabe4f55371cff4569750bb3996c55db6.tar.xz
linux-dev-4b6ab94eabe4f55371cff4569750bb3996c55db6.zip
perf subcmd: Create subcmd library
Move the subcommand-related files from perf to a new library named libsubcmd.a. Since we're moving files anyway, go ahead and rename 'exec_cmd.*' to 'exec-cmd.*' to be consistent with the naming of all the other files. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/c0a838d4c878ab17fee50998811612b2281355c1.1450193761.git.jpoimboe@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/sigchain.c')
-rw-r--r--tools/perf/util/sigchain.c53
1 files changed, 0 insertions, 53 deletions
diff --git a/tools/perf/util/sigchain.c b/tools/perf/util/sigchain.c
deleted file mode 100644
index 3537c348a18e..000000000000
--- a/tools/perf/util/sigchain.c
+++ /dev/null
@@ -1,53 +0,0 @@
-#include <signal.h>
-#include "subcmd-util.h"
-#include "sigchain.h"
-
-#define SIGCHAIN_MAX_SIGNALS 32
-
-struct sigchain_signal {
- sigchain_fun *old;
- int n;
- int alloc;
-};
-static struct sigchain_signal signals[SIGCHAIN_MAX_SIGNALS];
-
-static void check_signum(int sig)
-{
- if (sig < 1 || sig >= SIGCHAIN_MAX_SIGNALS)
- die("BUG: signal out of range: %d", sig);
-}
-
-static int sigchain_push(int sig, sigchain_fun f)
-{
- struct sigchain_signal *s = signals + sig;
- check_signum(sig);
-
- ALLOC_GROW(s->old, s->n + 1, s->alloc);
- s->old[s->n] = signal(sig, f);
- if (s->old[s->n] == SIG_ERR)
- return -1;
- s->n++;
- return 0;
-}
-
-int sigchain_pop(int sig)
-{
- struct sigchain_signal *s = signals + sig;
- check_signum(sig);
- if (s->n < 1)
- return 0;
-
- if (signal(sig, s->old[s->n - 1]) == SIG_ERR)
- return -1;
- s->n--;
- return 0;
-}
-
-void sigchain_push_common(sigchain_fun f)
-{
- sigchain_push(SIGINT, f);
- sigchain_push(SIGHUP, f);
- sigchain_push(SIGTERM, f);
- sigchain_push(SIGQUIT, f);
- sigchain_push(SIGPIPE, f);
-}