Mercurial > dropbear
comparison svr-chansession.c @ 893:860e3522f8fc
- Save errno in signal handlers
- Use _exit() in segv handler
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 15 Feb 2014 21:13:57 +0800 |
parents | aa689d140928 |
children | 5daedffd0769 |
comparison
equal
deleted
inserted
replaced
892:ae766a2c8fa7 | 893:860e3522f8fc |
---|---|
85 pid_t pid; | 85 pid_t pid; |
86 unsigned int i; | 86 unsigned int i; |
87 struct sigaction sa_chld; | 87 struct sigaction sa_chld; |
88 struct exitinfo *exit = NULL; | 88 struct exitinfo *exit = NULL; |
89 | 89 |
90 const int saved_errno = errno; | |
91 | |
90 TRACE(("enter sigchld handler")) | 92 TRACE(("enter sigchld handler")) |
91 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { | 93 while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { |
92 TRACE(("sigchld handler: pid %d", pid)) | 94 TRACE(("sigchld handler: pid %d", pid)) |
93 | 95 |
94 exit = NULL; | 96 exit = NULL; |
138 sa_chld.sa_handler = sesssigchild_handler; | 140 sa_chld.sa_handler = sesssigchild_handler; |
139 sa_chld.sa_flags = SA_NOCLDSTOP; | 141 sa_chld.sa_flags = SA_NOCLDSTOP; |
140 sigemptyset(&sa_chld.sa_mask); | 142 sigemptyset(&sa_chld.sa_mask); |
141 sigaction(SIGCHLD, &sa_chld, NULL); | 143 sigaction(SIGCHLD, &sa_chld, NULL); |
142 TRACE(("leave sigchld handler")) | 144 TRACE(("leave sigchld handler")) |
145 | |
146 errno = saved_errno; | |
143 } | 147 } |
144 | 148 |
145 /* send the exit status or the signal causing termination for a session */ | 149 /* send the exit status or the signal causing termination for a session */ |
146 static void send_exitsignalstatus(struct Channel *channel) { | 150 static void send_exitsignalstatus(struct Channel *channel) { |
147 | 151 |