Skip to content

Instantly share code, notes, and snippets.

@barmic
Created May 18, 2018 09:34
Show Gist options
  • Save barmic/c452326fdc0679af539c45b8cf869a38 to your computer and use it in GitHub Desktop.
Save barmic/c452326fdc0679af539c45b8cf869a38 to your computer and use it in GitHub Desktop.
Run idea
#!/bin/zsh
IDEA_SCRIPT=$(print -l /opt/idea-IU-*/bin/idea.sh | sort | tail -n1)
/usr/local/bin/reset-signal "${IDEA_SCRIPT}" &> /dev/null &
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
int
main (int argc, char **argv)
{
sigset_t sigs;
struct sigaction sa;
sigemptyset(&sigs);
sigaddset(&sigs, SIGINT);
sigaddset(&sigs, SIGTERM);
if (sigprocmask(SIG_UNBLOCK, &sigs, 0) != 0) {
fprintf(stderr, "sigprocmask failed\n");
return 1;
}
memset(&sa, 0, sizeof(sa));
sa.sa_handler = SIG_DFL;
if (sigaction(SIGINT, &sa, 0) != 0) {
fprintf(stderr, "sigaction failed for SIGINT\n");
return 1;
}
memset(&sa, 0, sizeof(sa));
sa.sa_handler = SIG_DFL;
if (sigaction(SIGTERM, &sa, 0) != 0) {
fprintf(stderr, "sigaction failed for SIGTERM\n");
return 1;
}
if (argc <= 1) {
fprintf(stderr, "usage: %s <command> [args...]\n", argv[0]);
return 1;
}
execvp(argv[1], argv + 1);
fprintf(stderr, "execvp(...) failed\n");
return 1;
}
@barmic
Copy link
Author

barmic commented May 18, 2018

Thanks to Julia Beliaeva

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment