Sha256: df977dafef5fe89706657c7fdb2e2579717427ac913ccfec000591eda38bc364

Contents?: true

Size: 951 Bytes

Versions: 33

Compression:

Stored size: 951 Bytes

Contents

/*
 * This program handles SIGINT and forwards it to another process.
 * It is intended to be run as PID 1.
 *
 * Docker starts processes with "docker run" as PID 1.
 * On Linux, the default signal handler for PID 1 ignores any signals.
 * Therefore Ctrl-C aka SIGINT is ignored per default.
 */

#include <unistd.h>
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>

int pid = 0;

void
handle_sigint (int signum)
{
  if(pid)
    kill(pid, SIGINT);
}

int main(int argc, char *argv[]){
  struct sigaction new_action;
  int status = -1;

  /* Set up the structure to specify the new action. */
  new_action.sa_handler = handle_sigint;
  sigemptyset (&new_action.sa_mask);
  new_action.sa_flags = 0;

  sigaction (SIGINT, &new_action, (void*)0);

  pid = fork();
  if(pid){
    wait(&status);
    return WEXITSTATUS(status);
  }else{
    status = execvp(argv[1], &argv[1]);
    perror("exec");
    return status;
  }
}

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
rake-compiler-dock-1.9.1 build/sigfw.c
rake-compiler-dock-1.9.0 build/sigfw.c
rake-compiler-dock-1.8.0 build/sigfw.c
rake-compiler-dock-1.7.1 build/sigfw.c
rake-compiler-dock-1.7.0 build/sigfw.c
rake-compiler-dock-1.7.0.rc1 build/sigfw.c
rake-compiler-dock-1.6.0 build/sigfw.c
rake-compiler-dock-1.5.2 build/sigfw.c
rake-compiler-dock-1.5.1 build/sigfw.c
rake-compiler-dock-1.5.0 build/sigfw.c
rake-compiler-dock-1.5.0.rc1 build/sigfw.c
rake-compiler-dock-1.4.0 build/sigfw.c
rake-compiler-dock-1.4.0.rc2 build/sigfw.c
rake-compiler-dock-1.4.0.rc1 build/sigfw.c
rake-compiler-dock-1.3.1 build/sigfw.c
rake-compiler-dock-1.3.0 build/sigfw.c
rake-compiler-dock-1.2.2 build/sigfw.c
rake-compiler-dock-1.2.1 build/sigfw.c
rake-compiler-dock-1.2.0 build/sigfw.c
win32-api-1.10.1 vendor/bundle/ruby/2.5.0/gems/rake-compiler-dock-0.7.2/build/sigfw.c