1

As described here ,using seccomp filters, we can block specific system calls when running example.c file.

The process will terminate and a "Bad system call" message will be printed:

$ ./example
Bad system call

I want to suppress the message.

Even this did not help:

$ ./example >/dev/null 2>/dev/null
Bad system call

2 Answers2

8

The first step is to understand where the Bad system call message comes from. It is a feature of your shell to tell you what signal caused your process to die. This message is not printed by your process, but by your shell. When the shell executes a program, it waits for it to finish using the waitpid system call. In the status parameter the reason for termination is described and the shell evaluates that field and kindly prints a message. Similarly when you manually kill a process launched from a shell with the SIGKILL signal, that shell will print Killed.

Now you already figured how to get rid of the message. You need to redirect the output of the shell by starting a subshell and redirecting its output.

Helmut Grohne
  • 6,578
  • 2
  • 31
  • 67
0

First, you are trying to ignore something, that you are not supposed to ignore. "Bad system call" seems a serious failure.

But, if you HAVE TO ignore it, try:

(./example) >/dev/null 2>/dev/null

I have not tested this, but I have seen this working, when simple >/dev/null 2>&1 don't work.

e.g. with (some-command) >/dev/null 2>/dev/null, if you kill -9 this some-command, the killed message printed on screen is not printed.

anishsane
  • 20,270
  • 5
  • 40
  • 73
  • Didn't work. I needed to do this because everything printed by my bash script is used by another script and I wanted to suppress this message. Now I think it is better to print only desired messages to a file and use that file in second script. – Mohammad Javad Naderi Jun 28 '13 at 08:38
  • 1
    If that message "Bad system call" is not present on stdout, then I hardly think, that this will be logged using any method & thus will be passed to that another script. Unless, you are doing some operations using screen or similar command. – anishsane Jun 28 '13 at 08:42
  • I put the command in my script `tester.sh`. Now when I run `./tester.sh 2>/dev/null`, that message doesn't appear. – Mohammad Javad Naderi Jun 28 '13 at 09:44