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

Function getlock

outdated/sys/mac/macunix.c:21–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21void
22getlock(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}

Callers 1

mainFunction · 0.70

Calls 8

getuidFunction · 0.85
openFunction · 0.85
writeFunction · 0.85
closeFunction · 0.85
set_levelfile_nameFunction · 0.70
getpidFunction · 0.50
raw_printfFunction · 0.50
panicFunction · 0.50

Tested by

no test coverage detected