Mercurial > hg > early-roguelike
comparison urogue/mdport.c @ 272:1db299e868b8
UltraRogue: add the autosave feature.
UltraRogue now automatically saves the game when SIGHUP or SIGTERM is
received.
| author | John "Elwin" Edwards | 
|---|---|
| date | Sun, 03 Sep 2017 19:58:22 -0400 | 
| parents | 7a96fede6cc8 | 
| children | 51ddbe7b992d | 
   comparison
  equal
  deleted
  inserted
  replaced
| 271:88bd51f231e7 | 272:1db299e868b8 | 
|---|---|
| 1269 nocbreak(); /* disable halfdelay mode if on */ | 1269 nocbreak(); /* disable halfdelay mode if on */ | 
| 1270 raw(); | 1270 raw(); | 
| 1271 | 1271 | 
| 1272 return(ch & 0x7F); | 1272 return(ch & 0x7F); | 
| 1273 } | 1273 } | 
| 1274 | |
| 1275 extern void auto_save(int sig); | |
| 1276 extern void fatal_handler(int sig); | |
| 1277 extern void quit_handler(int sig); | |
| 1278 | |
| 1279 void | |
| 1280 md_onsignal_autosave(void) | |
| 1281 { | |
| 1282 #ifdef SIGHUP | |
| 1283 signal(SIGHUP, auto_save); | |
| 1284 #endif | |
| 1285 #ifdef SIGQUIT | |
| 1286 signal(SIGQUIT, fatal_handler); | |
| 1287 #endif | |
| 1288 #ifdef SIGTERM | |
| 1289 signal(SIGTERM, auto_save); | |
| 1290 #endif | |
| 1291 #ifdef SIGINT | |
| 1292 signal(SIGINT, quit_handler); | |
| 1293 #endif | |
| 1294 return; | |
| 1295 } | |
| 1296 | |
| 1297 void | |
| 1298 md_ignore_signals(void) | |
| 1299 { | |
| 1300 #ifdef SIGHUP | |
| 1301 signal(SIGHUP, SIG_IGN); | |
| 1302 #endif | |
| 1303 #ifdef SIGQUIT | |
| 1304 signal(SIGQUIT, SIG_IGN); | |
| 1305 #endif | |
| 1306 #ifdef SIGTERM | |
| 1307 signal(SIGTERM, SIG_IGN); | |
| 1308 #endif | |
| 1309 #ifdef SIGINT | |
| 1310 signal(SIGINT, SIG_IGN); | |
| 1311 #endif | |
| 1312 return; | |
| 1313 } | 
