From 1059fae93b5fb783ab5b657573d17f0d9f4f4ed7 Mon Sep 17 00:00:00 2001 From: Joshua Kwan Date: Mon, 12 Jan 2004 17:32:47 +0000 Subject: [PATCH] solaris portability fixes git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@117 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- dgamelaunch.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index c8ee8ca..596fef5 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -68,6 +68,7 @@ # define ARRAY_SIZE(x) sizeof(x) / sizeof(x[0]) #endif +#include #include #include #include @@ -1060,7 +1061,8 @@ readfile (int nolock) if (!nolock) { - flock (fileno (fpl), LOCK_UN); + fl.l_type = F_UNLCK; + fcntl (fileno(fpl), F_SETLK, &fl); fclose (fpl); } fclose (fp); @@ -1162,13 +1164,21 @@ writefile (int requirenew) FILE *fp, *fpl; int i = 0; int my_done = 0; + struct flock fl = { 0 }; + + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + fl.l_start = 0; + fl.l_len = 0; fpl = fopen ("/dgl-lock", "r"); if (!fpl) graceful_exit (115); - if (flock (fileno (fpl), LOCK_EX)) + if (fcntl (fileno (fpl), F_SETLK, &fl)) graceful_exit (107); + fl.l_type = F_UNLCK; + freefile (); readfile (1); @@ -1202,7 +1212,7 @@ writefile (int requirenew) me->env); } - flock (fileno (fpl), LOCK_UN); + fcntl (fileno (fpl), F_UNLCK, &fl); fclose (fp); fclose (fpl); } -- 2.47.3