| 19 | } |
| 20 | |
| 21 | void |
| 22 | getlock(void) |
| 23 | { |
| 24 | int fd; |
| 25 | int pid = getpid(); /* Process ID */ |
| 26 | |
| 27 | Sprintf(gl.lock, "%d%s", getuid(), svp.plname); |
| 28 | set_levelfile_name(gl.lock, 0); |
| 29 | |
| 30 | if ((fd = open(gl.lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) { |
| 31 | raw_printf("Could not lock the game %s.", gl.lock); |
| 32 | panic("Another game in progress?"); |
| 33 | } |
| 34 | |
| 35 | if (write(fd, (char *) &pid, sizeof(pid)) != sizeof(pid)) { |
| 36 | raw_printf("Could not lock the game %s.", gl.lock); |
| 37 | panic("Disk locked?"); |
| 38 | } |
| 39 | close(fd); |
| 40 | } |
no test coverage detected