/[path-sandbox]/trunk/src/sandbox.c
Gentoo

Diff of /trunk/src/sandbox.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 267 Revision 268
162{ 162{
163 if (0 == stop_called) { 163 if (0 == stop_called) {
164 stop_called = 1; 164 stop_called = 1;
165 printf("sandbox: Caught signal %d in pid %d\n", 165 printf("sandbox: Caught signal %d in pid %d\n",
166 signum, getpid()); 166 signum, getpid());
167 167 } else {
168 if ((SIGUSR1 == signum) && (0 != child_pid)) 168 fprintf(stderr,
169 "sandbox: Signal already caught and busy still cleaning up!\n");
170 }
171}
172
173void usr1_handler(int signum, siginfo_t *siginfo, void *ucontext)
174{
175 if (0 == stop_called) {
176 stop_called = 1;
177 printf("sandbox: Caught signal %d in pid %d\n",
178 signum, getpid());
179
180 /* FIXME: This is really bad form, as we should kill the whole process
181 * tree, but currently that is too much work and not worth the
182 * effort. Thus we only kill the calling process and our child
183 * for now.
184 */
185 if (siginfo->si_pid > 0)
186 kill(siginfo->si_pid, SIGKILL);
169 kill(child_pid, SIGKILL); 187 kill(child_pid, SIGKILL);
170 } else { 188 } else {
171 fprintf(stderr, 189 fprintf(stderr,
172 "sandbox: Signal already caught and busy still cleaning up!\n"); 190 "sandbox: Signal already caught and busy still cleaning up!\n");
173 } 191 }
174} 192}
428 return 1; 446 return 1;
429} 447}
430 448
431int main(int argc, char **argv) 449int main(int argc, char **argv)
432{ 450{
451 struct sigaction act_new;
452
433 int i = 0, success = 1; 453 int i = 0, success = 1;
434 int sandbox_log_presence = 0; 454 int sandbox_log_presence = 0;
435 long len; 455 long len;
436 456
437 struct sandbox_info_t sandbox_info; 457 struct sandbox_info_t sandbox_info;
529 /* set up the required signal handlers */ 549 /* set up the required signal handlers */
530 signal(SIGHUP, &stop); 550 signal(SIGHUP, &stop);
531 signal(SIGINT, &stop); 551 signal(SIGINT, &stop);
532 signal(SIGQUIT, &stop); 552 signal(SIGQUIT, &stop);
533 signal(SIGTERM, &stop); 553 signal(SIGTERM, &stop);
534 signal(SIGUSR1, &stop); 554 act_new.sa_sigaction = usr1_handler;
555 sigemptyset (&act_new.sa_mask);
556 act_new.sa_flags = SA_SIGINFO | SA_RESTART;
557 sigaction (SIGUSR1, &act_new, NULL);
535 558
536 /* STARTING PROTECTED ENVIRONMENT */ 559 /* STARTING PROTECTED ENVIRONMENT */
537 if (print_debug) { 560 if (print_debug) {
538 printf("The protected environment has been started.\n"); 561 printf("The protected environment has been started.\n");
539 printf("--------------------------------------------------------------------------------\n"); 562 printf("--------------------------------------------------------------------------------\n");

Legend:
Removed from v.267  
changed lines
  Added in v.268

  ViewVC Help
Powered by ViewVC 1.1.20