… | |
… | |
979 | } |
979 | } |
980 | |
980 | |
981 | close_and_delete (fp, comp); |
981 | close_and_delete (fp, comp); |
982 | } |
982 | } |
983 | |
983 | |
984 | |
|
|
985 | /* |
984 | /* |
986 | * init() is called only once, when starting the program. |
985 | * init() is called only once, when starting the program. |
987 | */ |
986 | */ |
988 | |
987 | |
989 | void |
988 | void |
990 | init (int argc, char **argv) |
989 | init (int argc, char **argv) |
991 | { |
990 | { |
|
|
991 | init_done = 0; /* Must be done before init_signal() */ |
992 | rndm.seed (time (0)); |
992 | rndm.seed (time (0)); |
993 | |
993 | |
994 | init_done = 0; /* Must be done before init_signal() */ |
|
|
995 | logfile = stderr; |
994 | logfile = stderr; |
996 | parse_args (argc, argv, 1); /* First arg pass - right now it does |
995 | parse_args (argc, argv, 1); /* First arg pass - right now it does |
997 | * nothing, but in future specifying the |
996 | * nothing, but in future specifying the |
998 | * LibDir in this pass would be reasonable*/ |
997 | * LibDir in this pass would be reasonable*/ |
999 | |
998 | |
… | |
… | |
1252 | } |
1251 | } |
1253 | |
1252 | |
1254 | void |
1253 | void |
1255 | init_signals (void) |
1254 | init_signals (void) |
1256 | { |
1255 | { |
1257 | signal (SIGPIPE, SIG_IGN); |
1256 | // large stack, but it's important data we want to save, and it is not usually |
1258 | signal (SIGABRT, rec_sigabrt); |
1257 | // being physically allocated anyways |
1259 | signal (SIGQUIT, rec_sigquit); |
1258 | const size_t stacksize = 8 * 1024 * 1024 + SIGSTKSZ; |
1260 | signal (SIGSEGV, rec_sigsegv); |
1259 | |
1261 | signal (SIGBUS, rec_sigbus); |
1260 | stack_t ss; |
|
|
1261 | ss.ss_sp = malloc (stacksize); |
|
|
1262 | ss.ss_flags = 0; |
|
|
1263 | ss.ss_size = stacksize; |
|
|
1264 | sigaltstack (&ss, 0); |
|
|
1265 | |
|
|
1266 | struct sigaction sa; |
|
|
1267 | |
|
|
1268 | sigfillset (&sa.sa_mask); |
|
|
1269 | sa.sa_flags = SA_ONSTACK | SA_RESTART; |
|
|
1270 | |
|
|
1271 | sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); |
|
|
1272 | sa.sa_handler = rec_sigabrt; sigaction (SIGABRT, &sa, 0); |
|
|
1273 | sa.sa_handler = rec_sigquit; sigaction (SIGQUIT, &sa, 0); |
|
|
1274 | sa.sa_handler = rec_sigsegv; sigaction (SIGSEGV, &sa, 0); |
|
|
1275 | sa.sa_handler = rec_sigbus; sigaction (SIGBUS, &sa, 0); |
1262 | } |
1276 | } |
1263 | |
1277 | |
1264 | /* init_races() - reads the races file in the lib/ directory, then |
1278 | /* init_races() - reads the races file in the lib/ directory, then |
1265 | * overwrites old 'race' entries. This routine allow us to quickly |
1279 | * overwrites old 'race' entries. This routine allow us to quickly |
1266 | * re-configure the 'alignment' of monsters, objects. Useful for |
1280 | * re-configure the 'alignment' of monsters, objects. Useful for |