Search code examples
clinuxseccomp

Suppressing "Bad system call" Message


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

Solution

  • 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.