MCPcopy Create free account
hub / github.com/NetHack/NetHack / child

Function child

sys/unix/unixunix.c:369–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367
368#if defined(SHELL) || defined(DEF_PAGER) || defined(DEF_MAILREADER)
369int
370child(int wt)
371{
372 int f;
373
374 suspend_nhwindows((char *) 0); /* also calls end_screen() */
375#ifdef _M_UNIX
376 sco_mapon();
377#endif
378#ifdef __linux__
379 linux_mapon();
380#endif
381 if ((f = fork()) == 0) { /* child */
382 (void) setgid(getgid());
383 (void) setuid(getuid());
384#ifdef CHDIR
385 (void) chdir(getenv("HOME"));
386#endif
387 return 1;
388 }
389 if (f == -1) { /* cannot fork */
390 pline("Fork failed. Try again.");
391 return 0;
392 }
393 /* fork succeeded; wait for child to exit */
394#ifndef NO_SIGNAL
395 (void) signal(SIGINT, SIG_IGN);
396 (void) signal(SIGQUIT, SIG_IGN);
397#endif
398 (void) wait((int *) 0);
399#ifdef _M_UNIX
400 sco_mapoff();
401#endif
402#ifdef __linux__
403 linux_mapoff();
404#endif
405#ifndef NO_SIGNAL
406 (void) signal(SIGINT, (SIG_RET_TYPE) done1);
407 if (wizard)
408 (void) signal(SIGQUIT, SIG_DFL);
409#endif
410 if (wt) {
411 raw_print("");
412 wait_synch();
413 }
414 resume_nhwindows();
415 return 0;
416}
417#endif /* SHELL || DEF_PAGER || DEF_MAILREADER */
418
419#ifdef GETRES_SUPPORT

Callers 3

tty_display_fileFunction · 0.85
doshFunction · 0.85
readmailFunction · 0.85

Calls 9

sco_maponFunction · 0.85
linux_maponFunction · 0.85
getuidFunction · 0.85
sco_mapoffFunction · 0.85
linux_mapoffFunction · 0.85
raw_printFunction · 0.85
wait_synchFunction · 0.85
chdirFunction · 0.50
plineFunction · 0.50

Tested by

no test coverage detected