File star-lock.diff of Package star

--- star/fifo.c
+++ star/fifo.c	2009-03-10 17:52:09.292002187 +0100
@@ -477,13 +477,42 @@ LOCAL int
 swait(f)
 	int	f;
 {
-		int	ret;
+	int		ret, err;
 	unsigned char	c;
+	struct flock	lock;
+	useconds_t	wait;
+
+	wait = 500000;
+	lock.l_type = F_RDLCK;
+	lock.l_whence = SEEK_CUR;
+	lock.l_start = 0;
+	lock.l_len = 0;
+	do {
+	    err = fcntl(f, F_SETLK, &lock);
+	    if (err < 0) {
+		err = geterrno();
+		if (err == EINTR)
+		    continue;
+		if ((err == EACCES || err == EAGAIN) && (wait > 0)) {
+		    usleep(10000);
+		    wait -= 10000;
+		    continue;
+		}
+		errmsg("Can not get lock on semaphore wait for file descriptor\n");
+		exprstats(-1);
+	    }
+	} while (0);
 
 	seterrno(0);
 	do {
 		ret = read(f, &c, 1);
 	} while (ret < 0 && geterrno() == EINTR);
+
+	lock.l_type = F_UNLCK;
+	do {
+	    err = fcntl(f, F_SETLK, &lock);
+	} while (err < 0 && geterrno() == EINTR);
+
 	if (ret < 0 || (ret == 0 && pid)) {
 		/*
 		 * If pid != 0, this is the foreground process
openSUSE Build Service is sponsored by