libutil: add O_NOCTTY back to old pty open code
[minix.git] / lib / libc / sys-minix / flock.c
blob37a69677a5c13a739e919c94a0fe647ae4bef84d
1 /* Library routines
3 * Porting to Minix 2.0.0
4 * Author: Giovanni Falzoni <gfalzoni@pointest.com>
5 */
7 #include <sys/cdefs.h>
8 #include "namespace.h"
9 #include <lib.h>
11 #include <sys/types.h>
12 #include <fcntl.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <unistd.h>
17 #ifdef __weak_alias
18 __weak_alias(flock, _flock)
19 #endif
22 * Name: int flock(int fd, int mode);
23 * Function: Implements the flock function in Minix.
25 int flock(int fd, int mode)
27 struct flock lck;
28 register int retcode;
30 memset((void *) &lck, 0, sizeof(struct flock));
31 lck.l_type = mode & ~LOCK_NB;
32 lck.l_pid = getpid();
33 if ((retcode = fcntl(fd, mode & LOCK_NB ? F_SETLK : F_SETLKW, &lck)) < 0 && errno == EAGAIN)
34 errno = EWOULDBLOCK;
35 return retcode;
38 /** flock.c **/