| 61 | #endif /* SELF_RECOVER */ |
| 62 | |
| 63 | void |
| 64 | getlock(void) |
| 65 | { |
| 66 | int fd, c, ci, ct; |
| 67 | int fcmask = FCMASK; |
| 68 | char tbuf[BUFSZ]; |
| 69 | const char *fq_lock; |
| 70 | #if defined(MSDOS) && defined(NO_TERMS) |
| 71 | int grmode = iflags.grmode; |
| 72 | #endif |
| 73 | /* we ignore QUIT and INT at this point */ |
| 74 | if (!lock_file(HLOCK, LOCKPREFIX, 10)) { |
| 75 | wait_synch(); |
| 76 | #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) |
| 77 | chdirx(orgdir, 0); |
| 78 | #endif |
| 79 | error("Quitting."); |
| 80 | } |
| 81 | |
| 82 | /* regularize(lock); */ /* already done in pcmain */ |
| 83 | Sprintf(tbuf, "%s", fqname(gl.lock, LEVELPREFIX, 0)); |
| 84 | set_levelfile_name(gl.lock, 0); |
| 85 | fq_lock = fqname(gl.lock, LEVELPREFIX, 1); |
| 86 | if ((fd = open(fq_lock, 0)) == -1) { |
| 87 | if (errno == ENOENT) |
| 88 | goto gotlock; /* no such file */ |
| 89 | #if defined(CHDIR) && !defined(NOCWD_ASSUMPTIONS) |
| 90 | chdirx(orgdir, 0); |
| 91 | #endif |
| 92 | perror(fq_lock); |
| 93 | unlock_file(HLOCK); |
| 94 | error("Cannot open %s", fq_lock); |
| 95 | } |
| 96 | |
| 97 | (void) nhclose(fd); |
| 98 | |
| 99 | if (iflags.window_inited) { |
| 100 | #ifdef SELF_RECOVER |
| 101 | c = y_n("There are files from a game in progress under your name. " |
| 102 | "Recover?"); |
| 103 | #else |
| 104 | pline("There is already a game in progress under your name."); |
| 105 | pline("You may be able to use \"recover %s\" to get it back.\n", |
| 106 | tbuf); |
| 107 | c = y_n("Do you want to destroy the old game?"); |
| 108 | #endif |
| 109 | } else { |
| 110 | #if defined(MSDOS) && defined(NO_TERMS) |
| 111 | grmode = iflags.grmode; |
| 112 | if (grmode) |
| 113 | gr_finish(); |
| 114 | #endif |
| 115 | c = 'n'; |
| 116 | ct = 0; |
| 117 | #ifdef SELF_RECOVER |
| 118 | msmsg("There are files from a game in progress under your name. " |
| 119 | "Recover? [yn]"); |
| 120 | #else |
no test coverage detected