libutil: add O_NOCTTY back to old pty open code
[minix.git] / lib / libc / sys-minix / shmget.c
blobf1d9b7064aea759b5178d9b4a9378f95bbbbed5c
1 #define _SYSTEM 1
2 #define _MINIX 1
3 #include <sys/cdefs.h>
4 #include <lib.h>
5 #include "namespace.h"
7 #include <minix/rs.h>
8 #include <sys/types.h>
9 #include <sys/ipc.h>
10 #include <sys/shm.h>
11 #include <stdlib.h>
12 #include <errno.h>
15 #ifdef __weak_alias
16 __weak_alias(shmget, _shmget)
17 #endif
19 static int get_ipc_endpt(endpoint_t *pt)
21 return minix_rs_lookup("ipc", pt);
24 /* Get shared memory segment. */
25 int shmget(key_t key, size_t size, int shmflg)
27 message m;
28 endpoint_t ipc_pt;
29 int r;
31 if (get_ipc_endpt(&ipc_pt) != OK) {
32 errno = ENOSYS;
33 return -1;
36 m.SHMGET_KEY = key;
37 m.SHMGET_SIZE = size;
38 m.SHMGET_FLAG = shmflg;
40 r = _syscall(ipc_pt, IPC_SHMGET, &m);
41 if (r != OK)
42 return r;
43 return m.SHMGET_RETID;