summaryrefslogtreecommitdiffstats
path: root/x11vnc/connections.c
diff options
context:
space:
mode:
authorrunge <runge>2006-02-20 19:19:30 +0000
committerrunge <runge>2006-02-20 19:19:30 +0000
commit603b5667b64aa5aaea0aa7e575fb4cb2c2b6d7c7 (patch)
tree582b98055d3f8edf42fff571a3443ff0dfaa1256 /x11vnc/connections.c
parent4b8cc33e39e1d2f4eb459312659eff873a41e4db (diff)
downloadlibtdevnc-603b5667b64aa5aaea0aa7e575fb4cb2c2b6d7c7.tar.gz
libtdevnc-603b5667b64aa5aaea0aa7e575fb4cb2c2b6d7c7.zip
fix some non-gcc compiler warnings and signals in x11vnc
Diffstat (limited to 'x11vnc/connections.c')
-rw-r--r--x11vnc/connections.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/x11vnc/connections.c b/x11vnc/connections.c
index 800d443..4415f38 100644
--- a/x11vnc/connections.c
+++ b/x11vnc/connections.c
@@ -431,15 +431,39 @@ static int run_user_command(char *cmd, rfbClientPtr client, char *mode) {
#if LIBVNCSERVER_HAVE_FORK
{
pid_t pid, pidw;
- if ((pid = fork()) > 0) {
- pidw = waitpid(pid, &rc, 0);
- } else if (pid == -1) {
- fprintf(stderr, "could not fork\n");
- rfbLogPerror("fork");
- rc = system(cmd);
+ struct sigaction sa, intr, quit;
+ sigset_t omask;
+
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGINT, &sa, &intr);
+ sigaction(SIGQUIT, &sa, &quit);
+
+ sigaddset(&sa.sa_mask, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sa.sa_mask, &omask);
+
+ if ((pid = fork()) > 0 || pid == -1) {
+
+ if (pid != -1) {
+ pidw = waitpid(pid, &rc, 0);
+ }
+
+ sigaction(SIGINT, &intr, (struct sigaction *) NULL);
+ sigaction(SIGQUIT, &quit, (struct sigaction *) NULL);
+ sigprocmask(SIG_SETMASK, &omask, (sigset_t *) NULL);
+
+ if (pid == -1) {
+ fprintf(stderr, "could not fork\n");
+ rfbLogPerror("fork");
+ rc = system(cmd);
+ }
} else {
/* this should close port 5900, etc.. */
int fd;
+ sigaction(SIGINT, &intr, (struct sigaction *) NULL);
+ sigaction(SIGQUIT, &quit, (struct sigaction *) NULL);
+ sigprocmask(SIG_SETMASK, &omask, (sigset_t *) NULL);
for (fd=3; fd<256; fd++) {
close(fd);
}