|
|
1.1 root 1: /* $Header: /src386/STREAMS/coh.386/RCS/sys6.c,v 2.1 93/08/09 13:36:55 bin Exp Locker: bin $ */
2: /*
3: * POSIX.1-oriented system calls for Coherent.
4: *
5: * Conventions: as elsewhere, system call handlers have the same name as the
6: * user would use but prefixed by a 'u'. Internal data interfaces have the
7: * same name as a user function if they have the same signature, which is a
8: * good thing for testing, and can save on redundant prototypes. Wherever
9: * possible, we use such function-call interfaces rather than get involved in
10: * the disgusting mess that is the U area or process-table mechanisms.
11: */
12: /*
13: * $Log: sys6.c,v $
14: * Revision 2.1 93/08/09 13:36:55 bin
15: * Kernel 82 changes
16: *
17: * Revision 2.2 93/07/26 14:55:33 nigel
18: * Nigel's R80
19: *
20: */
21:
22: #include <common/ccompat.h>
23: #include <sys/signal.h>
24: #include <unistd.h>
25:
26:
27: /*
28: *-STATUS:
29: * POSIX.1
30: *
31: *-NAME:
32: * sigaction () Detailed signal management
33: *
34: *-SYNOPSIS:
35: * #include <signal.h>
36: *
37: * int sigaction (int sig, const struct sigaction * act,
38: * struct sigaction * oact);
39: *
40: *-DESCRIPTION:
41: * sigaction () allows the calling process to examine and/or specify the
42: * action to be taken on delivery of a specific signal.
43: *
44: * "sig" specifies the signal and can be assigned any of the signals
45: * specified in signal(5) except SIGKILL and SIGSTOP.
46: *
47: * If the argument "arg" is not NULL, it points to a structure specifying
48: * the new action to be taken when delivering "sig". If the argument
49: * "oact" is not NULL, it points to a structure where the action
50: * previously associated with "sig" is to be stored on return from
51: * sigaction ().
52: *
53: * The "sigaction" structure includes the following members:
54: * void (* sa_handler) ();
55: * sigset_t sa_mask;
56: * int sa_flags;
57: *
58: * "sa_handler" specifies the disposition of the signal and may take any
59: * of the values specified in signal (5).
60: *
61: * "sa_mask" specifies a set of signals to be blocked while the signal
62: * handler is active. On entry to the signal handler, that set of signals
63: * is added to the set of signals already being blocked when the signal
64: * is delivered. In addition, the signal that caused the handler to be
65: * executed will also be blocked, unless the SA_NODEFER flag has been
66: * specified. SIGSTOP and SIGKILL cannot be blocked (the system silently
67: * enforces this restriction).
68: *
69: * "sa_flags" specifies a set of flags used to modify the behaviour of
70: * the signal. It is formed by a logical OR of any of the following
71: * values (only SA_CLDSTOP is available to System V, Release 3
72: * applications):
73: *
74: * SA_NOCLDSTOP If set and "sig" equals SIGCHLD, "sig" will not be
75: * sent to the calling process when its child processes
76: * stop or continue.
77: *
78: * SA_NOCLDWAIT If set and "sig" equals SIGCHLD, the system will not
79: * create zombie processes when children of the calling
80: * process exit. If the calling process subsequently
81: * issues a wait (), it blocks until all of the calling
82: * process's child processes terminate, and then returns
83: * a value of -1 with "errno" set to ECHILD.
84: *
85: * SA_ONSTACK If set and the signal is caught and an alternate
86: * signal stack has been declared with sigaltstack (),
87: * the signal is delivered to the calling process on that
88: * stack. Otherwise, the signal is delivered on the
89: * same stack as the main program.
90: *
91: * SA_RESETHAND If set and the signal is caught, the disposition of
92: * the signal is reset to SIG_DFL, and the signal will
93: * not be blocked on entry to the signal handler (SIGILL,
94: * SIGTRAP, and SIGPWR cannot be automatically reset when
95: * delivered; the system silently enforces this
96: * restriction).
97: *
98: * SA_NODEFER If set and the signal is caught, the signal will not
99: * be automatically blocked by the kernel while it is
100: * being caught.
101: *
102: * SA_RESTART If set and the signal is caught, a system call that
103: * is interrupted by the execution of this signal's
104: * handler is transparently restarted by the system.
105: * Otherwise, the system call returns an EINTR error.
106: *
107: * SA_SIGINFO If cleared and the signal is caught, "sig" is passed
108: * as the only argument to the signal-catching function.
109: * If set and the signal is caught, pending signals of
110: * type "sig" are reliably queued to the calling process
111: * and two additional arguments are passed to the signal-
112: * catching function. If the second argument is not equal
113: * to NULL, it points to a "siginfo_t" structure
114: * containing the reason why the signal was generated;
115: * the third argument points to a "ucontext_t" structure
116: * containing the receiving process's context when the
117: * signal was delivered.
118: *
119: * sigaction () fails if any of the following is true:
120: *
121: * EINVAL The value of the "sig" argument is not a valid signal
122: * number or is equal to SIGKILL or SIGSTOP.
123: *
124: * EFAULT "act" or "oact" points outside the process's allocated
125: * address space.
126: *
127: *-DIAGNOSTICS:
128: * On success, sigaction () returns zero. On failure, it returns -1 and
129: * sets "errno" to indicate the error.
130: */
131:
132: #if __USE_PROTO__
133: int usigaction (int sig, __CONST__ struct sigaction * act,
134: struct sigaction * oact)
135: #else
136: int
137: usigaction (sig, act, oact)
138: int sig;
139: __CONST__ struct sigaction
140: * act;
141: struct sigaction * oact;
142: #endif
143: {
144: struct sigaction temp;
145: /*
146: * Once we validate the user pointers, we *must* take a local copy of
147: * either the previous signal setting or the data pointed to by "act"
148: * so that the caller is free to use the same pointer for both input
149: * and output arguments. Naturally, we must totally validate the new
150: * data before storing anything back to the user, irrespective of how
151: * convenient it might be to let a lower layer deal with this.
152: */
153: return -1;
154: }
155:
156:
157: /*
158: *-STATUS:
159: * POSIX.1
160: *
161: *-NAME:
162: * sigpending () Examine signals that are blocked and pending
163: *
164: *-SYNOPSIS:
165: * #include <signal.h>
166: *
167: * int sigpending (sigset_t * set);
168: *
169: *-DESCRIPTION:
170: * The sigpending () function retrieves those signals that have been sent
171: * to the calling process but are being blocked from delivery by the
172: * calling process's signal mask. The signals are stored in the space
173: * pointed to by the argument "set".
174: *
175: * sigpending () fails if any of the following are true:
176: *
177: * EFAULT The "set" argument points outside the process's
178: * allocated address space.
179: *
180: *-DIAGNOSTICS:
181: * On success, sigpending () returns zero. On failure, it returns -1 and
182: * sets "errno" to indicate the error.
183: */
184:
185: #if __USE_PROTO__
186: int usigpending (o_sigset_t * set)
187: #else
188: int
189: usigpending (set)
190: o_sigset_t * set;
191: #endif
192: {
193: return -1;
194: }
195:
196:
197: /*
198: *-STATUS:
199: * POSIX.1
200: *
201: *-NAME:
202: * sigprocmask () Change or examine signal mask
203: *
204: *-SYNOPSIS:
205: * #include <signal.h>
206: *
207: * int sigprocmask (int how, const sigset_t * set, sigset_t * oset);
208: *
209: *-DESCRIPTION:
210: * The sigprocmask () function is used to examine and/or change the
211: * calling process's signal mask. If the value of "how" is SIG_BLOCK, the
212: * set pointed to by the argument "set" is added to the current signal
213: * mask. If "how" is SIG_UNBLOCK, the set pointed to by the argument
214: * "set" is removed from the current signal mask. If "how" is
215: * SIG_SETMASK, the current signal mask is replaced by the set pointed
216: * to by the argument "set". If the argument "oset" is not NULL, the
217: * previous mask is stored in the space pointed to by "oset". If the
218: * value of the argument "set" is NULL, the value "how" is not
219: * significant and the process's signal mask is unchanged; thus, the call
220: * can be used to enquire about currently blocked signals.
221: *
222: * If there are any pending unblocked signals after the call to
223: * sigprocmask (), at least one of those signals will be delivered before
224: * the call to sigprocmask () returns.
225: *
226: * It is not possible to block those signals that cannot be ignored [see
227: * sigaction ()]; this restriction is silently imposed by the system.
228: *
229: * If sigprocmask () fails, the process's signal mask is not changed.
230: *
231: * sigprocmask () fails if any of the following are true:
232: *
233: * EINVAL The value of the "how" argument is not equal to one of
234: * the defined values.
235: *
236: * EFAULT The value of "set" or "oset" points outside the
237: * process's allocated address space.
238: *
239: *-DIAGNOSTICS:
240: * On success, sigprocmask () returns zero. On failure, it returns -1 and
241: * sets "errno" to indicate the error.
242: */
243:
244: #if __USE_PROTO__
245: int usigprocmask (int how, __CONST__ o_sigset_t * set, o_sigset_t * oset)
246: #else
247: int
248: usigprocmask (how, set, oset)
249: int how;
250: __CONST__ o_sigset_t
251: * set;
252: o_sigset_t * oset;
253: #endif
254: {
255: o_sigset_t tmp;
256: /*
257: * Once we validate the user pointers, we *must* either take a local
258: * copy of the previous signal mask or the data pointed at by "set" so
259: * that the user is free to use the same pointer for both input and
260: * output arguments.
261: */
262: return -1;
263: }
264:
265:
266: /*
267: *-STATUS:
268: * POSIX.1
269: *
270: *-NAME:
271: * fpathconf ()
272: * pathconf () get configurable pathname variables
273: *
274: *-SYNOPSIS:
275: * #include <unistd.h>
276: *
277: * long fpathconf (int fildes, int name);
278: * long pathconf (const char * path, int name);
279: *
280: *-DESCRIPTION:
281: * The functions fpathconf () and pathconf () return the current value of
282: * a configurable limit or option associated with a file or directory.
283: * The "path" argument points to the pathname of a file or directory;
284: * "fildes" is an open file descriptor; and "name" is the symbolic
285: * constant (defined in <unistd.h>) representing the configurable system
286: * limit or option to be returned.
287: *
288: * The values returned by pathconf () or fpathconf () depend on the type
289: * of file specified by "path" or "fildes". The following table contains
290: * the symbolic constants supported by pathconf () and fpathconf ()
291: * along with the POSIX defined return value. The return value is based
292: * on the type of file specified by "path" or "fildes".
293: *
294: * _PC_LINK_MAX The maximum value of a file's link count. If "path" or
295: * "fildes" refers to a directory, the value returned
296: * applies to the directory itself.
297: *
298: * _PC_MAX_CANON The number of bytes in a terminal canonical input
299: * queue. The behaviour is undefined if "path" or
300: * "fildes" does not refer to a terminal file.
301: *
302: * _PC_MAX_INPUT The number of bytes for which space will be available
303: * in a terminal input queue. The behaviour is undefined
304: * "path" or "fildes" does not refer to a terminal file.
305: *
306: * _PC_NAME_MAX The number of bytes in a filename. The behaviour is
307: * undefined if "path" or "fildes" does not refer to a
308: * directory. The value returned applies to the filenames
309: * within the directory.
310: *
311: * _PC_PATH_MAX The number of bytes in a pathname. The behaviour is
312: * undefined if "path" or "fildes" does not refer to a
313: * directory. The value returned is the maximum length of
314: * a relative pathname when the specified directory is
315: * the working directory.
316: *
317: * _PC_PIPE_BUF The number of bytes that can be written atomically
318: * when writing to a pipe. If "path" or "files" refers to
319: * a pipe or FIFO, the value returned applies to the FIFO
320: * itself. If "path" or "fildes" refers to a directory,
321: * the value returned applies to any FIFOs that exist or
322: * can be created within the directory. If "path" or
323: * "fildes" refer to any other type of file, the
324: * behaviour is undefined.
325: *
326: * _PC_CHOWN_RESTRICTED The use of the chown () function is restricted
327: * to a process with appropriate priveleges, and to
328: * changing the group ID of a file only to the effective
329: * group ID of the process or to one of its supplementary
330: * group IDs. If "path" or "fildes" refers to a
331: * directory, the value returned applies to any files,
332: * other than directories, that exist or can be created
333: * within the directory.
334: *
335: * _PC_NO_TRUNC Pathname components longer than NAME_MAX generate an
336: * error. The behaviour is undefined if "path" or
337: * "fildes" does not refer to a directory. The value
338: * returned applies to the filenames within the
339: * directory.
340: * _PC_VDISABLE Terminal special characters can be disabled using this
341: * character value, if it is defined. The behaviour is
342: * undefined if "path" or "filedes" does not refer to a
343: * terminal file.
344: *
345: * The value of the configurable system limit or option specified by
346: * "name" does not change during the lifetime of the calling process.
347: *
348: * fpathconf () fails if the following is true:
349: *
350: * EBADF "fildes" is not a valid file descriptor.
351: *
352: * pathconf () fails if any of the following are true:
353: *
354: * EACCES Search permission is denied for a component of the
355: * path prefix.
356: *
357: * ELOOP Too many symbolic links are encountered while
358: * translating "path".
359: *
360: * EMULTIHOP Components of "path" require hopping to multiple
361: * remote machines and the file system type does not
362: * allow it.
363: *
364: * ENAMETOOLONG The length of a pathname component exceeds PATH_MAX,
365: * or a pathname component is longer than NAME_MAX while
366: * _POSIX_NO_TRUNC is in effect.
367: *
368: * ENOENT "path" is needed for the command specified and the
369: * named file does not exist or if the "path" argument
370: * points to an empty string.
371: *
372: * ENOLINK "path" points to a remote machine and the link to that
373: * machine is no longer active.
374: *
375: * ENOTDIR A component of the path prefix is not a directory.
376: *
377: * Both fpathconf () and pathconf () fail if the following is true:
378: *
379: * EINVAL if "name" is an invalid value.
380: *
381: *-DIAGNOSTICS:
382: * If fpathconf () or pathconf () is invoked with an invalid symbolic
383: * constant or the symbolic constant corresponds to a configurable system
384: * limit or option not supported on the system, a value of -1 is returned
385: * to the invoking process. If the function fails because the
386: * configurable system limit or option corresponding to "name" is not
387: * supported on the system the value of "errno" is not changed.
388: */
389:
390: #if __USE_PROTO__
391: int ufpathconf (int fildes, int name)
392: #else
393: int
394: ufpathconf (fildes, name)
395: int fildes;
396: int name;
397: #endif
398: {
399: return -1;
400: }
401:
402:
403: #if __USE_PROTO__
404: int upathconf (__CONST__ char * path, int name)
405: #else
406: int
407: upathconf (path, name)
408: __CONST__ char * path;
409: int name;
410: #endif
411: {
412: return -1;
413: }
414:
415:
416: /*
417: *-STATUS:
418: * POSIX.1
419: *
420: *-NAME:
421: * sysconf () get configurable system variables
422: *
423: *-SYNOPSIS:
424: * #include <unistd.h>
425: *
426: * long sysconf (int name);
427: *
428: *-DESCRIPTION:
429: * The sysconf () function provides a method for the application to
430: * determine the current value of a configurable system limit or option.
431: *
432: * The "name" argument represents the system variable to be queried. The
433: * following table lists the minimal set of system variables from
434: * <limits.h> and <unistd.h> that can be returned by sysconf (), and the
435: * symbolic constants that are the corresponding values used for "name":
436: *
437: * NAME: RETURN VALUE:
438: * _SC_ARG_MAX ARG_MAX
439: * _SC_CHILD_MAX CHILD_MAX
440: * _SC_CLK_TCK CLK_TCK
441: * _SC_NGROUPS_MAX NGROUPS_MAX
442: * _SC_OPEN_MAX OPEN_MAX
443: * _SC_PASS_MAX PASS_MAX
444: * _SC_PAGESIZE PAGESIZE
445: * _SC_JOB_CONTROL _POSIX_JOB_CONTROL
446: * _SC_SAVED_IDS _POSIX_SAVED_IDS
447: * _SC_VERSION _POSIX_VERSION
448: * _SC_XOPEN_VERSION _XOPEN_VERSION
449: * _SC_LOGNAME_MAX LOGNAME_MAX
450: *
451: * The value of CLK_TCK may be variable and it should not be assumed that
452: * CLK_TCK is a compile-time constant. The value of CLK_TCK is the same
453: * as the value of sysconf (_SC_CLK_TCK).
454: *
455: *-DIAGNOSTICS:
456: * If "name" is an invalid value, sysconf () will return -1 and set
457: * "errno" to indicate the error. If sysconf () fails due to a value of
458: * "name" that is not defined on the system, the function will returne
459: * a value of -1 without changing the value of "errno".
460: *
461: *-NOTES:
462: * A call to setrlimit () may cause the value of OPEN_MAX to change on
463: * System V, Release 4-compatible systems.
464: */
465:
466: #if __USE_PROTO__
467: long usysconf (int name)
468: #else
469: long
470: usysconf (name)
471: int name;
472: #endif
473: {
474: return -1;
475: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.