1 /* Copyright (C) 1995,1996,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 /* Make GNU/Linux libc declare everything it has. */
30 #include "libguile/_scm.h"
31 #include "libguile/fports.h"
32 #include "libguile/scmsigs.h"
33 #include "libguile/feature.h"
34 #include "libguile/strings.h"
35 #include "libguile/vectors.h"
36 #include "libguile/lang.h"
38 #include "libguile/validate.h"
39 #include "libguile/posix.h"
45 #ifdef TIME_WITH_SYS_TIME
46 # include <sys/time.h>
50 # include <sys/time.h>
60 extern char *ttyname();
64 #ifdef LIBC_H_WITH_UNISTD_H
68 #include <sys/types.h>
78 #ifdef HAVE_WINSOCK2_H
83 /* Some defines for Windows here. */
85 # define pipe(fd) _pipe (fd, 256, O_BINARY)
86 #endif /* __MINGW32__ */
89 # include <sys/wait.h>
92 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
95 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
100 extern char ** environ
;
105 #ifdef HAVE_SYS_UTSNAME_H
106 #include <sys/utsname.h>
109 #ifdef HAVE_SETLOCALE
113 #if HAVE_LIBCRYPT && HAVE_CRYPT_H
117 #if HAVE_SYS_RESOURCE_H
118 # include <sys/resource.h>
122 # include <sys/file.h>
125 /* Some Unix systems don't define these. CPP hair is dangerous, but
126 this seems safe enough... */
143 /* On NextStep, <utime.h> doesn't define struct utime, unless we
144 #define _POSIX_SOURCE before #including it. I think this is less
145 of a kludge than defining struct utimbuf ourselves. */
146 #ifdef UTIMBUF_NEEDS_POSIX
147 #define _POSIX_SOURCE
150 #ifdef HAVE_SYS_UTIME_H
151 #include <sys/utime.h>
158 /* Please don't add any more #includes or #defines here. The hack
159 above means that _POSIX_SOURCE may be #defined, which will
160 encourage header files to do strange things. */
163 SCM_SYMBOL (sym_read_pipe
, "read pipe");
164 SCM_SYMBOL (sym_write_pipe
, "write pipe");
166 SCM_DEFINE (scm_pipe
, "pipe", 0, 0, 0,
168 "Return a newly created pipe: a pair of ports which are linked\n"
169 "together on the local machine. The @emph{car} is the input\n"
170 "port and the @emph{cdr} is the output port. Data written (and\n"
171 "flushed) to the output port can be read from the input port.\n"
172 "Pipes are commonly used for communication with a newly forked\n"
173 "child process. The need to flush the output port can be\n"
174 "avoided by making it unbuffered using @code{setvbuf}.\n"
176 "Writes occur atomically provided the size of the data in bytes\n"
177 "is not greater than the value of @code{PIPE_BUF}. Note that\n"
178 "the output port is likely to block if too much data (typically\n"
179 "equal to @code{PIPE_BUF}) has been written but not yet read\n"
180 "from the input port.")
181 #define FUNC_NAME s_scm_pipe
190 p_rd
= scm_fdes_to_port (fd
[0], "r", sym_read_pipe
);
191 p_wt
= scm_fdes_to_port (fd
[1], "w", sym_write_pipe
);
192 return scm_cons (p_rd
, p_wt
);
197 #ifdef HAVE_GETGROUPS
198 SCM_DEFINE (scm_getgroups
, "getgroups", 0, 0, 0,
200 "Return a vector of integers representing the current\n"
201 "supplementary group IDs.")
202 #define FUNC_NAME s_scm_getgroups
209 ngroups
= getgroups (0, NULL
);
213 size
= ngroups
* sizeof (GETGROUPS_T
);
214 groups
= scm_malloc (size
);
215 getgroups (ngroups
, groups
);
217 result
= scm_c_make_vector (ngroups
, SCM_UNDEFINED
);
220 SCM
* ve
= SCM_WRITABLE_VELTS(result
);
222 while (--ngroups
>= 0)
223 ve
[ngroups
] = SCM_MAKINUM (groups
[ngroups
]);
232 SCM_DEFINE (scm_getpwuid
, "getpw", 0, 1, 0,
234 "Look up an entry in the user database. @var{obj} can be an integer,\n"
235 "a string, or omitted, giving the behaviour of getpwuid, getpwnam\n"
236 "or getpwent respectively.")
237 #define FUNC_NAME s_scm_getpwuid
239 struct passwd
*entry
;
241 SCM result
= scm_c_make_vector (7, SCM_UNSPECIFIED
);
242 if (SCM_UNBNDP (user
) || SCM_FALSEP (user
))
244 SCM_SYSCALL (entry
= getpwent ());
250 else if (SCM_INUMP (user
))
252 entry
= getpwuid (SCM_INUM (user
));
256 SCM_VALIDATE_STRING (1, user
);
257 entry
= getpwnam (SCM_STRING_CHARS (user
));
260 SCM_MISC_ERROR ("entry not found", SCM_EOL
);
262 SCM_VECTOR_SET(result
, 0, scm_makfrom0str (entry
->pw_name
));
263 SCM_VECTOR_SET(result
, 1, scm_makfrom0str (entry
->pw_passwd
));
264 SCM_VECTOR_SET(result
, 2, scm_ulong2num ((unsigned long) entry
->pw_uid
));
265 SCM_VECTOR_SET(result
, 3, scm_ulong2num ((unsigned long) entry
->pw_gid
));
266 SCM_VECTOR_SET(result
, 4, scm_makfrom0str (entry
->pw_gecos
));
268 SCM_VECTOR_SET(result
, 5, scm_makfrom0str (""));
270 SCM_VECTOR_SET(result
, 5, scm_makfrom0str (entry
->pw_dir
));
271 if (!entry
->pw_shell
)
272 SCM_VECTOR_SET(result
, 6, scm_makfrom0str (""));
274 SCM_VECTOR_SET(result
, 6, scm_makfrom0str (entry
->pw_shell
));
278 #endif /* HAVE_GETPWENT */
282 SCM_DEFINE (scm_setpwent
, "setpw", 0, 1, 0,
284 "If called with a true argument, initialize or reset the password data\n"
285 "stream. Otherwise, close the stream. The @code{setpwent} and\n"
286 "@code{endpwent} procedures are implemented on top of this.")
287 #define FUNC_NAME s_scm_setpwent
289 if (SCM_UNBNDP (arg
) || SCM_FALSEP (arg
))
293 return SCM_UNSPECIFIED
;
300 /* Combines getgrgid and getgrnam. */
301 SCM_DEFINE (scm_getgrgid
, "getgr", 0, 1, 0,
303 "Look up an entry in the group database. @var{obj} can be an integer,\n"
304 "a string, or omitted, giving the behaviour of getgrgid, getgrnam\n"
305 "or getgrent respectively.")
306 #define FUNC_NAME s_scm_getgrgid
309 SCM result
= scm_c_make_vector (4, SCM_UNSPECIFIED
);
311 if (SCM_UNBNDP (name
) || SCM_FALSEP (name
))
313 SCM_SYSCALL (entry
= getgrent ());
319 else if (SCM_INUMP (name
))
320 SCM_SYSCALL (entry
= getgrgid (SCM_INUM (name
)));
323 SCM_VALIDATE_STRING (1, name
);
324 SCM_SYSCALL (entry
= getgrnam (SCM_STRING_CHARS (name
)));
329 SCM_VECTOR_SET(result
, 0, scm_makfrom0str (entry
->gr_name
));
330 SCM_VECTOR_SET(result
, 1, scm_makfrom0str (entry
->gr_passwd
));
331 SCM_VECTOR_SET(result
, 2, scm_ulong2num ((unsigned long) entry
->gr_gid
));
332 SCM_VECTOR_SET(result
, 3, scm_makfromstrs (-1, entry
->gr_mem
));
339 SCM_DEFINE (scm_setgrent
, "setgr", 0, 1, 0,
341 "If called with a true argument, initialize or reset the group data\n"
342 "stream. Otherwise, close the stream. The @code{setgrent} and\n"
343 "@code{endgrent} procedures are implemented on top of this.")
344 #define FUNC_NAME s_scm_setgrent
346 if (SCM_UNBNDP (arg
) || SCM_FALSEP (arg
))
350 return SCM_UNSPECIFIED
;
353 #endif /* HAVE_GETGRENT */
356 SCM_DEFINE (scm_kill
, "kill", 2, 0, 0,
358 "Sends a signal to the specified process or group of processes.\n\n"
359 "@var{pid} specifies the processes to which the signal is sent:\n\n"
361 "@item @var{pid} greater than 0\n"
362 "The process whose identifier is @var{pid}.\n"
363 "@item @var{pid} equal to 0\n"
364 "All processes in the current process group.\n"
365 "@item @var{pid} less than -1\n"
366 "The process group whose identifier is -@var{pid}\n"
367 "@item @var{pid} equal to -1\n"
368 "If the process is privileged, all processes except for some special\n"
369 "system processes. Otherwise, all processes with the current effective\n"
372 "@var{sig} should be specified using a variable corresponding to\n"
373 "the Unix symbolic name, e.g.,\n\n"
378 "Interrupt signal.\n"
380 #define FUNC_NAME s_scm_kill
382 SCM_VALIDATE_INUM (1, pid
);
383 SCM_VALIDATE_INUM (2, sig
);
384 /* Signal values are interned in scm_init_posix(). */
386 if (kill ((int) SCM_INUM (pid
), (int) SCM_INUM (sig
)) != 0)
388 if ((int) SCM_INUM (pid
) == getpid ())
389 if (raise ((int) SCM_INUM (sig
)) != 0)
392 return SCM_UNSPECIFIED
;
397 SCM_DEFINE (scm_waitpid
, "waitpid", 1, 1, 0,
398 (SCM pid
, SCM options
),
399 "This procedure collects status information from a child process which\n"
400 "has terminated or (optionally) stopped. Normally it will\n"
401 "suspend the calling process until this can be done. If more than one\n"
402 "child process is eligible then one will be chosen by the operating system.\n\n"
403 "The value of @var{pid} determines the behaviour:\n\n"
405 "@item @var{pid} greater than 0\n"
406 "Request status information from the specified child process.\n"
407 "@item @var{pid} equal to -1 or WAIT_ANY\n"
408 "Request status information for any child process.\n"
409 "@item @var{pid} equal to 0 or WAIT_MYPGRP\n"
410 "Request status information for any child process in the current process\n"
412 "@item @var{pid} less than -1\n"
413 "Request status information for any child process whose process group ID\n"
416 "The @var{options} argument, if supplied, should be the bitwise OR of the\n"
417 "values of zero or more of the following variables:\n\n"
419 "Return immediately even if there are no child processes to be collected.\n"
421 "@defvar WUNTRACED\n"
422 "Report status information for stopped processes as well as terminated\n"
425 "The return value is a pair containing:\n\n"
428 "The process ID of the child process, or 0 if @code{WNOHANG} was\n"
429 "specified and no process was collected.\n"
431 "The integer status value.\n"
433 #define FUNC_NAME s_scm_waitpid
438 SCM_VALIDATE_INUM (1, pid
);
439 if (SCM_UNBNDP (options
))
443 SCM_VALIDATE_INUM (2, options
);
444 /* Flags are interned in scm_init_posix. */
445 ioptions
= SCM_INUM (options
);
447 SCM_SYSCALL (i
= waitpid (SCM_INUM (pid
), &status
, ioptions
));
450 return scm_cons (SCM_MAKINUM (0L + i
), SCM_MAKINUM (0L + status
));
453 #endif /* HAVE_WAITPID */
456 SCM_DEFINE (scm_status_exit_val
, "status:exit-val", 1, 0, 0,
458 "Return the exit status value, as would be set if a process\n"
459 "ended normally through a call to @code{exit} or @code{_exit},\n"
460 "if any, otherwise @code{#f}.")
461 #define FUNC_NAME s_scm_status_exit_val
465 SCM_VALIDATE_INUM (1, status
);
467 /* On Ultrix, the WIF... macros assume their argument is an lvalue;
468 go figure. SCM_INUM does not yield an lvalue. */
469 lstatus
= SCM_INUM (status
);
470 if (WIFEXITED (lstatus
))
471 return (SCM_MAKINUM (WEXITSTATUS (lstatus
)));
477 SCM_DEFINE (scm_status_term_sig
, "status:term-sig", 1, 0, 0,
479 "Return the signal number which terminated the process, if any,\n"
480 "otherwise @code{#f}.")
481 #define FUNC_NAME s_scm_status_term_sig
485 SCM_VALIDATE_INUM (1, status
);
487 lstatus
= SCM_INUM (status
);
488 if (WIFSIGNALED (lstatus
))
489 return SCM_MAKINUM (WTERMSIG (lstatus
));
495 SCM_DEFINE (scm_status_stop_sig
, "status:stop-sig", 1, 0, 0,
497 "Return the signal number which stopped the process, if any,\n"
498 "otherwise @code{#f}.")
499 #define FUNC_NAME s_scm_status_stop_sig
503 SCM_VALIDATE_INUM (1, status
);
505 lstatus
= SCM_INUM (status
);
506 if (WIFSTOPPED (lstatus
))
507 return SCM_MAKINUM (WSTOPSIG (lstatus
));
512 #endif /* __MINGW32__ */
515 SCM_DEFINE (scm_getppid
, "getppid", 0, 0, 0,
517 "Return an integer representing the process ID of the parent\n"
519 #define FUNC_NAME s_scm_getppid
521 return SCM_MAKINUM (0L + getppid ());
524 #endif /* HAVE_GETPPID */
528 SCM_DEFINE (scm_getuid
, "getuid", 0, 0, 0,
530 "Return an integer representing the current real user ID.")
531 #define FUNC_NAME s_scm_getuid
533 return SCM_MAKINUM (0L + getuid ());
539 SCM_DEFINE (scm_getgid
, "getgid", 0, 0, 0,
541 "Return an integer representing the current real group ID.")
542 #define FUNC_NAME s_scm_getgid
544 return SCM_MAKINUM (0L + getgid ());
550 SCM_DEFINE (scm_geteuid
, "geteuid", 0, 0, 0,
552 "Return an integer representing the current effective user ID.\n"
553 "If the system does not support effective IDs, then the real ID\n"
554 "is returned. @code{(provided? 'EIDs)} reports whether the\n"
555 "system supports effective IDs.")
556 #define FUNC_NAME s_scm_geteuid
559 return SCM_MAKINUM (0L + geteuid ());
561 return SCM_MAKINUM (0L + getuid ());
567 SCM_DEFINE (scm_getegid
, "getegid", 0, 0, 0,
569 "Return an integer representing the current effective group ID.\n"
570 "If the system does not support effective IDs, then the real ID\n"
571 "is returned. @code{(provided? 'EIDs)} reports whether the\n"
572 "system supports effective IDs.")
573 #define FUNC_NAME s_scm_getegid
576 return SCM_MAKINUM (0L + getegid ());
578 return SCM_MAKINUM (0L + getgid ());
584 SCM_DEFINE (scm_setuid
, "setuid", 1, 0, 0,
586 "Sets both the real and effective user IDs to the integer @var{id}, provided\n"
587 "the process has appropriate privileges.\n"
588 "The return value is unspecified.")
589 #define FUNC_NAME s_scm_setuid
591 SCM_VALIDATE_INUM (1, id
);
592 if (setuid (SCM_INUM (id
)) != 0)
594 return SCM_UNSPECIFIED
;
598 SCM_DEFINE (scm_setgid
, "setgid", 1, 0, 0,
600 "Sets both the real and effective group IDs to the integer @var{id}, provided\n"
601 "the process has appropriate privileges.\n"
602 "The return value is unspecified.")
603 #define FUNC_NAME s_scm_setgid
605 SCM_VALIDATE_INUM (1, id
);
606 if (setgid (SCM_INUM (id
)) != 0)
608 return SCM_UNSPECIFIED
;
612 SCM_DEFINE (scm_seteuid
, "seteuid", 1, 0, 0,
614 "Sets the effective user ID to the integer @var{id}, provided the process\n"
615 "has appropriate privileges. If effective IDs are not supported, the\n"
616 "real ID is set instead -- @code{(provided? 'EIDs)} reports whether the\n"
617 "system supports effective IDs.\n"
618 "The return value is unspecified.")
619 #define FUNC_NAME s_scm_seteuid
623 SCM_VALIDATE_INUM (1, id
);
625 rv
= seteuid (SCM_INUM (id
));
627 rv
= setuid (SCM_INUM (id
));
631 return SCM_UNSPECIFIED
;
634 #endif /* __MINGW32__ */
638 SCM_DEFINE (scm_setegid
, "setegid", 1, 0, 0,
640 "Sets the effective group ID to the integer @var{id}, provided the process\n"
641 "has appropriate privileges. If effective IDs are not supported, the\n"
642 "real ID is set instead -- @code{(provided? 'EIDs)} reports whether the\n"
643 "system supports effective IDs.\n"
644 "The return value is unspecified.")
645 #define FUNC_NAME s_scm_setegid
649 SCM_VALIDATE_INUM (1, id
);
651 rv
= setegid (SCM_INUM (id
));
653 rv
= setgid (SCM_INUM (id
));
657 return SCM_UNSPECIFIED
;
665 SCM_DEFINE (scm_getpgrp
, "getpgrp", 0, 0, 0,
667 "Return an integer representing the current process group ID.\n"
668 "This is the POSIX definition, not BSD.")
669 #define FUNC_NAME s_scm_getpgrp
672 fn
= (int (*) ()) getpgrp
;
673 return SCM_MAKINUM (fn (0));
676 #endif /* HAVE_GETPGRP */
680 SCM_DEFINE (scm_setpgid
, "setpgid", 2, 0, 0,
682 "Move the process @var{pid} into the process group @var{pgid}. @var{pid} or\n"
683 "@var{pgid} must be integers: they can be zero to indicate the ID of the\n"
685 "Fails on systems that do not support job control.\n"
686 "The return value is unspecified.")
687 #define FUNC_NAME s_scm_setpgid
689 SCM_VALIDATE_INUM (1, pid
);
690 SCM_VALIDATE_INUM (2, pgid
);
691 /* FIXME(?): may be known as setpgrp. */
692 if (setpgid (SCM_INUM (pid
), SCM_INUM (pgid
)) != 0)
694 return SCM_UNSPECIFIED
;
697 #endif /* HAVE_SETPGID */
700 SCM_DEFINE (scm_setsid
, "setsid", 0, 0, 0,
702 "Creates a new session. The current process becomes the session leader\n"
703 "and is put in a new process group. The process will be detached\n"
704 "from its controlling terminal if it has one.\n"
705 "The return value is an integer representing the new process group ID.")
706 #define FUNC_NAME s_scm_setsid
708 pid_t sid
= setsid ();
711 return SCM_UNSPECIFIED
;
714 #endif /* HAVE_SETSID */
717 SCM_DEFINE (scm_ttyname
, "ttyname", 1, 0, 0,
719 "Return a string with the name of the serial terminal device\n"
720 "underlying @var{port}.")
721 #define FUNC_NAME s_scm_ttyname
726 port
= SCM_COERCE_OUTPORT (port
);
727 SCM_VALIDATE_OPPORT (1, port
);
728 if (!SCM_FPORTP (port
))
730 fd
= SCM_FPORT_FDES (port
);
731 SCM_SYSCALL (result
= ttyname (fd
));
734 /* result could be overwritten by another call to ttyname */
735 return (scm_makfrom0str (result
));
738 #endif /* HAVE_TTYNAME */
741 SCM_DEFINE (scm_ctermid
, "ctermid", 0, 0, 0,
743 "Return a string containing the file name of the controlling\n"
744 "terminal for the current process.")
745 #define FUNC_NAME s_scm_ctermid
747 char *result
= ctermid (NULL
);
750 return scm_makfrom0str (result
);
753 #endif /* HAVE_CTERMID */
755 #ifdef HAVE_TCGETPGRP
756 SCM_DEFINE (scm_tcgetpgrp
, "tcgetpgrp", 1, 0, 0,
758 "Return the process group ID of the foreground process group\n"
759 "associated with the terminal open on the file descriptor\n"
760 "underlying @var{port}.\n"
762 "If there is no foreground process group, the return value is a\n"
763 "number greater than 1 that does not match the process group ID\n"
764 "of any existing process group. This can happen if all of the\n"
765 "processes in the job that was formerly the foreground job have\n"
766 "terminated, and no other job has yet been moved into the\n"
768 #define FUNC_NAME s_scm_tcgetpgrp
773 port
= SCM_COERCE_OUTPORT (port
);
775 SCM_VALIDATE_OPFPORT (1, port
);
776 fd
= SCM_FPORT_FDES (port
);
777 if ((pgid
= tcgetpgrp (fd
)) == -1)
779 return SCM_MAKINUM (pgid
);
782 #endif /* HAVE_TCGETPGRP */
784 #ifdef HAVE_TCSETPGRP
785 SCM_DEFINE (scm_tcsetpgrp
, "tcsetpgrp", 2, 0, 0,
786 (SCM port
, SCM pgid
),
787 "Set the foreground process group ID for the terminal used by the file\n"
788 "descriptor underlying @var{port} to the integer @var{pgid}.\n"
789 "The calling process\n"
790 "must be a member of the same session as @var{pgid} and must have the same\n"
791 "controlling terminal. The return value is unspecified.")
792 #define FUNC_NAME s_scm_tcsetpgrp
796 port
= SCM_COERCE_OUTPORT (port
);
798 SCM_VALIDATE_OPFPORT (1, port
);
799 SCM_VALIDATE_INUM (2, pgid
);
800 fd
= SCM_FPORT_FDES (port
);
801 if (tcsetpgrp (fd
, SCM_INUM (pgid
)) == -1)
803 return SCM_UNSPECIFIED
;
806 #endif /* HAVE_TCSETPGRP */
808 /* return a newly allocated array of char pointers to each of the strings
809 in args, with a terminating NULL pointer. */
810 /* Note: a similar function is defined in dynl.c, but we don't necessarily
811 want to export it. */
812 static char **allocate_string_pointers (SCM args
)
815 int n_args
= scm_ilength (args
);
818 SCM_ASSERT (n_args
>= 0, args
, SCM_ARGn
, "allocate_string_pointers");
819 result
= (char **) scm_malloc ((n_args
+ 1) * sizeof (char *));
820 result
[n_args
] = NULL
;
821 for (i
= 0; i
< n_args
; i
++)
823 SCM car
= SCM_CAR (args
);
825 if (!SCM_STRINGP (car
))
828 scm_wrong_type_arg ("allocate_string_pointers", SCM_ARGn
, car
);
830 result
[i
] = SCM_STRING_CHARS (SCM_CAR (args
));
831 args
= SCM_CDR (args
);
836 SCM_DEFINE (scm_execl
, "execl", 1, 0, 1,
837 (SCM filename
, SCM args
),
838 "Executes the file named by @var{path} as a new process image.\n"
839 "The remaining arguments are supplied to the process; from a C program\n"
840 "they are accessible as the @code{argv} argument to @code{main}.\n"
841 "Conventionally the first @var{arg} is the same as @var{path}.\n"
842 "All arguments must be strings.\n\n"
843 "If @var{arg} is missing, @var{path} is executed with a null\n"
844 "argument list, which may have system-dependent side-effects.\n\n"
845 "This procedure is currently implemented using the @code{execv} system\n"
846 "call, but we call it @code{execl} because of its Scheme calling interface.")
847 #define FUNC_NAME s_scm_execl
850 SCM_VALIDATE_STRING (1, filename
);
851 execargv
= allocate_string_pointers (args
);
852 execv (SCM_STRING_CHARS (filename
), execargv
);
859 SCM_DEFINE (scm_execlp
, "execlp", 1, 0, 1,
860 (SCM filename
, SCM args
),
861 "Similar to @code{execl}, however if\n"
862 "@var{filename} does not contain a slash\n"
863 "then the file to execute will be located by searching the\n"
864 "directories listed in the @code{PATH} environment variable.\n\n"
865 "This procedure is currently implemented using the @code{execvp} system\n"
866 "call, but we call it @code{execlp} because of its Scheme calling interface.")
867 #define FUNC_NAME s_scm_execlp
870 SCM_VALIDATE_STRING (1, filename
);
871 execargv
= allocate_string_pointers (args
);
872 execvp (SCM_STRING_CHARS (filename
), execargv
);
880 environ_list_to_c (SCM envlist
, int arg
, const char *proc
)
886 num_strings
= scm_ilength (envlist
);
887 SCM_ASSERT (num_strings
>= 0, envlist
, arg
, proc
);
888 result
= (char **) scm_malloc ((num_strings
+ 1) * sizeof (char *));
890 scm_memory_error (proc
);
891 for (i
= 0; !SCM_NULL_OR_NIL_P (envlist
); ++i
, envlist
= SCM_CDR (envlist
))
893 SCM str
= SCM_CAR (envlist
);
897 SCM_ASSERT (SCM_STRINGP (str
), envlist
, arg
, proc
);
898 len
= SCM_STRING_LENGTH (str
);
899 src
= SCM_STRING_CHARS (str
);
900 result
[i
] = scm_malloc (len
+ 1);
901 if (result
[i
] == NULL
)
902 scm_memory_error (proc
);
903 memcpy (result
[i
], src
, len
);
910 SCM_DEFINE (scm_execle
, "execle", 2, 0, 1,
911 (SCM filename
, SCM env
, SCM args
),
912 "Similar to @code{execl}, but the environment of the new process is\n"
913 "specified by @var{env}, which must be a list of strings as returned by the\n"
914 "@code{environ} procedure.\n\n"
915 "This procedure is currently implemented using the @code{execve} system\n"
916 "call, but we call it @code{execle} because of its Scheme calling interface.")
917 #define FUNC_NAME s_scm_execle
922 SCM_VALIDATE_STRING (1, filename
);
924 execargv
= allocate_string_pointers (args
);
925 exec_env
= environ_list_to_c (env
, SCM_ARG2
, FUNC_NAME
);
926 execve (SCM_STRING_CHARS (filename
), execargv
, exec_env
);
934 SCM_DEFINE (scm_fork
, "primitive-fork", 0, 0, 0,
936 "Creates a new \"child\" process by duplicating the current \"parent\" process.\n"
937 "In the child the return value is 0. In the parent the return value is\n"
938 "the integer process ID of the child.\n\n"
939 "This procedure has been renamed from @code{fork} to avoid a naming conflict\n"
940 "with the scsh fork.")
941 #define FUNC_NAME s_scm_fork
947 return SCM_MAKINUM (0L+pid
);
950 #endif /* HAVE_FORK */
953 # include "win32-uname.h"
956 #if defined (HAVE_UNAME) || defined (__MINGW32__)
957 SCM_DEFINE (scm_uname
, "uname", 0, 0, 0,
959 "Return an object with some information about the computer\n"
960 "system the program is running on.")
961 #define FUNC_NAME s_scm_uname
964 SCM result
= scm_c_make_vector (5, SCM_UNSPECIFIED
);
965 if (uname (&buf
) < 0)
967 SCM_VECTOR_SET(result
, 0, scm_makfrom0str (buf
.sysname
));
968 SCM_VECTOR_SET(result
, 1, scm_makfrom0str (buf
.nodename
));
969 SCM_VECTOR_SET(result
, 2, scm_makfrom0str (buf
.release
));
970 SCM_VECTOR_SET(result
, 3, scm_makfrom0str (buf
.version
));
971 SCM_VECTOR_SET(result
, 4, scm_makfrom0str (buf
.machine
));
974 SCM_VECTOR_SET(result, 5, scm_makfrom0str (buf.domainname));
979 #endif /* HAVE_UNAME */
981 SCM_DEFINE (scm_environ
, "environ", 0, 1, 0,
983 "If @var{env} is omitted, return the current environment (in the\n"
984 "Unix sense) as a list of strings. Otherwise set the current\n"
985 "environment, which is also the default environment for child\n"
986 "processes, to the supplied list of strings. Each member of\n"
987 "@var{env} should be of the form @code{NAME=VALUE} and values of\n"
988 "@code{NAME} should not be duplicated. If @var{env} is supplied\n"
989 "then the return value is unspecified.")
990 #define FUNC_NAME s_scm_environ
992 if (SCM_UNBNDP (env
))
993 return scm_makfromstrs (-1, environ
);
998 new_environ
= environ_list_to_c (env
, SCM_ARG1
, FUNC_NAME
);
999 /* Free the old environment, except when called for the first
1004 static int first
= 1;
1007 for (ep
= environ
; *ep
!= NULL
; ep
++)
1009 free ((char *) environ
);
1013 environ
= new_environ
;
1014 return SCM_UNSPECIFIED
;
1021 SCM_DEFINE (scm_tmpnam
, "tmpnam", 0, 0, 0,
1023 "Return a name in the file system that does not match any\n"
1024 "existing file. However there is no guarantee that another\n"
1025 "process will not create the file after @code{tmpnam} is called.\n"
1026 "Care should be taken if opening the file, e.g., use the\n"
1027 "@code{O_EXCL} open flag or use @code{mkstemp!} instead.")
1028 #define FUNC_NAME s_scm_tmpnam
1030 char name
[L_tmpnam
];
1033 SCM_SYSCALL (rv
= tmpnam (name
));
1035 /* not SCM_SYSERROR since errno probably not set. */
1036 SCM_MISC_ERROR ("tmpnam failed", SCM_EOL
);
1037 return scm_makfrom0str (name
);
1043 #ifndef HAVE_MKSTEMP
1044 extern int mkstemp (char *);
1047 SCM_DEFINE (scm_mkstemp
, "mkstemp!", 1, 0, 0,
1049 "Create a new unique file in the file system and returns a new\n"
1050 "buffered port open for reading and writing to the file.\n"
1051 "@var{tmpl} is a string specifying where the file should be\n"
1052 "created: it must end with @code{XXXXXX} and will be changed in\n"
1053 "place to return the name of the temporary file.")
1054 #define FUNC_NAME s_scm_mkstemp
1059 SCM_VALIDATE_STRING_COPY (1, tmpl
, c_tmpl
);
1060 SCM_SYSCALL (rv
= mkstemp (c_tmpl
));
1063 return scm_fdes_to_port (rv
, "w+", tmpl
);
1067 SCM_DEFINE (scm_utime
, "utime", 1, 2, 0,
1068 (SCM pathname
, SCM actime
, SCM modtime
),
1069 "@code{utime} sets the access and modification times for the\n"
1070 "file named by @var{path}. If @var{actime} or @var{modtime} is\n"
1071 "not supplied, then the current time is used. @var{actime} and\n"
1072 "@var{modtime} must be integer time values as returned by the\n"
1073 "@code{current-time} procedure.\n"
1075 "(utime \"foo\" (- (current-time) 3600))\n"
1077 "will set the access time to one hour in the past and the\n"
1078 "modification time to the current time.")
1079 #define FUNC_NAME s_scm_utime
1082 struct utimbuf utm_tmp
;
1084 SCM_VALIDATE_STRING (1, pathname
);
1085 if (SCM_UNBNDP (actime
))
1086 SCM_SYSCALL (time (&utm_tmp
.actime
));
1088 utm_tmp
.actime
= SCM_NUM2ULONG (2, actime
);
1090 if (SCM_UNBNDP (modtime
))
1091 SCM_SYSCALL (time (&utm_tmp
.modtime
));
1093 utm_tmp
.modtime
= SCM_NUM2ULONG (3, modtime
);
1095 SCM_SYSCALL (rv
= utime (SCM_STRING_CHARS (pathname
), &utm_tmp
));
1098 return SCM_UNSPECIFIED
;
1102 SCM_DEFINE (scm_access
, "access?", 2, 0, 0,
1103 (SCM path
, SCM how
),
1104 "Return @code{#t} if @var{path} corresponds to an existing file\n"
1105 "and the current process has the type of access specified by\n"
1106 "@var{how}, otherwise @code{#f}. @var{how} should be specified\n"
1107 "using the values of the variables listed below. Multiple\n"
1108 "values can be combined using a bitwise or, in which case\n"
1109 "@code{#t} will only be returned if all accesses are granted.\n"
1111 "Permissions are checked using the real id of the current\n"
1112 "process, not the effective id, although it's the effective id\n"
1113 "which determines whether the access would actually be granted.\n"
1116 "test for read permission.\n"
1119 "test for write permission.\n"
1122 "test for execute permission.\n"
1125 "test for existence of the file.\n"
1127 #define FUNC_NAME s_scm_access
1131 SCM_VALIDATE_STRING (1, path
);
1132 SCM_VALIDATE_INUM (2, how
);
1133 rv
= access (SCM_STRING_CHARS (path
), SCM_INUM (how
));
1134 return SCM_NEGATE_BOOL(rv
);
1138 SCM_DEFINE (scm_getpid
, "getpid", 0, 0, 0,
1140 "Return an integer representing the current process ID.")
1141 #define FUNC_NAME s_scm_getpid
1143 return SCM_MAKINUM ((unsigned long) getpid ());
1147 SCM_DEFINE (scm_putenv
, "putenv", 1, 0, 0,
1149 "Modifies the environment of the current process, which is\n"
1150 "also the default environment inherited by child processes.\n\n"
1151 "If @var{string} is of the form @code{NAME=VALUE} then it will be written\n"
1152 "directly into the environment, replacing any existing environment string\n"
1154 "name matching @code{NAME}. If @var{string} does not contain an equal\n"
1155 "sign, then any existing string with name matching @var{string} will\n"
1157 "The return value is unspecified.")
1158 #define FUNC_NAME s_scm_putenv
1163 SCM_VALIDATE_STRING (1, str
);
1165 if (strchr (SCM_STRING_CHARS (str
), '=') == NULL
)
1167 /* No '=' in argument means we should remove the variable from
1168 the environment. Not all putenvs understand this. To be
1169 safe, we do it explicitely using unsetenv. */
1170 unsetenv (SCM_STRING_CHARS (str
));
1174 /* must make a new copy to be left in the environment, safe from gc. */
1175 ptr
= scm_malloc (SCM_STRING_LENGTH (str
) + 1);
1178 strncpy (ptr
, SCM_STRING_CHARS (str
), SCM_STRING_LENGTH (str
));
1179 ptr
[SCM_STRING_LENGTH (str
)] = 0;
1184 return SCM_UNSPECIFIED
;
1188 #ifdef HAVE_SETLOCALE
1189 SCM_DEFINE (scm_setlocale
, "setlocale", 1, 1, 0,
1190 (SCM category
, SCM locale
),
1191 "If @var{locale} is omitted, return the current value of the\n"
1192 "specified locale category as a system-dependent string.\n"
1193 "@var{category} should be specified using the values\n"
1194 "@code{LC_COLLATE}, @code{LC_ALL} etc.\n"
1196 "Otherwise the specified locale category is set to the string\n"
1197 "@var{locale} and the new value is returned as a\n"
1198 "system-dependent string. If @var{locale} is an empty string,\n"
1199 "the locale will be set using environment variables.")
1200 #define FUNC_NAME s_scm_setlocale
1205 SCM_VALIDATE_INUM (1, category
);
1206 if (SCM_UNBNDP (locale
))
1212 SCM_VALIDATE_STRING (2, locale
);
1213 clocale
= SCM_STRING_CHARS (locale
);
1216 rv
= setlocale (SCM_INUM (category
), clocale
);
1219 return scm_makfrom0str (rv
);
1222 #endif /* HAVE_SETLOCALE */
1225 SCM_DEFINE (scm_mknod
, "mknod", 4, 0, 0,
1226 (SCM path
, SCM type
, SCM perms
, SCM dev
),
1227 "Creates a new special file, such as a file corresponding to a device.\n"
1228 "@var{path} specifies the name of the file. @var{type} should\n"
1229 "be one of the following symbols:\n"
1230 "regular, directory, symlink, block-special, char-special,\n"
1231 "fifo, or socket. @var{perms} (an integer) specifies the file permissions.\n"
1232 "@var{dev} (an integer) specifies which device the special file refers\n"
1233 "to. Its exact interpretation depends on the kind of special file\n"
1234 "being created.\n\n"
1237 "(mknod \"/dev/fd0\" 'block-special #o660 (+ (* 2 256) 2))\n"
1239 "The return value is unspecified.")
1240 #define FUNC_NAME s_scm_mknod
1246 SCM_VALIDATE_STRING (1, path
);
1247 SCM_VALIDATE_SYMBOL (2, type
);
1248 SCM_VALIDATE_INUM (3, perms
);
1249 SCM_VALIDATE_INUM (4, dev
);
1251 p
= SCM_SYMBOL_CHARS (type
);
1252 if (strcmp (p
, "regular") == 0)
1254 else if (strcmp (p
, "directory") == 0)
1256 else if (strcmp (p
, "symlink") == 0)
1258 else if (strcmp (p
, "block-special") == 0)
1260 else if (strcmp (p
, "char-special") == 0)
1262 else if (strcmp (p
, "fifo") == 0)
1265 else if (strcmp (p
, "socket") == 0)
1269 SCM_OUT_OF_RANGE (2, type
);
1271 SCM_SYSCALL (val
= mknod (SCM_STRING_CHARS (path
), ctype
| SCM_INUM (perms
),
1275 return SCM_UNSPECIFIED
;
1278 #endif /* HAVE_MKNOD */
1281 SCM_DEFINE (scm_nice
, "nice", 1, 0, 0,
1283 "Increment the priority of the current process by @var{incr}. A higher\n"
1284 "priority value means that the process runs less often.\n"
1285 "The return value is unspecified.")
1286 #define FUNC_NAME s_scm_nice
1288 SCM_VALIDATE_INUM (1, incr
);
1289 if (nice(SCM_INUM(incr
)) != 0)
1291 return SCM_UNSPECIFIED
;
1294 #endif /* HAVE_NICE */
1297 SCM_DEFINE (scm_sync
, "sync", 0, 0, 0,
1299 "Flush the operating system disk buffers.\n"
1300 "The return value is unspecified.")
1301 #define FUNC_NAME s_scm_sync
1304 return SCM_UNSPECIFIED
;
1307 #endif /* HAVE_SYNC */
1309 #if HAVE_LIBCRYPT && HAVE_CRYPT_H
1310 SCM_DEFINE (scm_crypt
, "crypt", 2, 0, 0,
1311 (SCM key
, SCM salt
),
1312 "Encrypt @var{key} using @var{salt} as the salt value to the\n"
1313 "crypt(3) library call.")
1314 #define FUNC_NAME s_scm_crypt
1318 SCM_VALIDATE_STRING (1, key
);
1319 SCM_VALIDATE_STRING (2, salt
);
1321 p
= crypt (SCM_STRING_CHARS (key
), SCM_STRING_CHARS (salt
));
1322 return scm_makfrom0str (p
);
1325 #endif /* HAVE_LIBCRYPT && HAVE_CRYPT_H */
1328 SCM_DEFINE (scm_chroot
, "chroot", 1, 0, 0,
1330 "Change the root directory to that specified in @var{path}.\n"
1331 "This directory will be used for path names beginning with\n"
1332 "@file{/}. The root directory is inherited by all children\n"
1333 "of the current process. Only the superuser may change the\n"
1335 #define FUNC_NAME s_scm_chroot
1337 SCM_VALIDATE_STRING (1, path
);
1339 if (chroot (SCM_STRING_CHARS (path
)) == -1)
1341 return SCM_UNSPECIFIED
;
1344 #endif /* HAVE_CHROOT */
1348 /* Wrapper function to supplying `getlogin()' under Windows. */
1349 static char * getlogin (void)
1351 static char user
[256];
1352 static unsigned long len
= 256;
1354 if (!GetUserName (user
, &len
))
1358 #endif /* __MINGW32__ */
1361 #if defined (HAVE_GETLOGIN) || defined (__MINGW32__)
1362 SCM_DEFINE (scm_getlogin
, "getlogin", 0, 0, 0,
1364 "Return a string containing the name of the user logged in on\n"
1365 "the controlling terminal of the process, or @code{#f} if this\n"
1366 "information cannot be obtained.")
1367 #define FUNC_NAME s_scm_getlogin
1374 return scm_makfrom0str (p
);
1377 #endif /* HAVE_GETLOGIN */
1380 SCM_DEFINE (scm_cuserid
, "cuserid", 0, 0, 0,
1382 "Return a string containing a user name associated with the\n"
1383 "effective user id of the process. Return @code{#f} if this\n"
1384 "information cannot be obtained.")
1385 #define FUNC_NAME s_scm_cuserid
1392 return scm_makfrom0str (p
);
1395 #endif /* HAVE_CUSERID */
1397 #if HAVE_GETPRIORITY
1398 SCM_DEFINE (scm_getpriority
, "getpriority", 2, 0, 0,
1399 (SCM which
, SCM who
),
1400 "Return the scheduling priority of the process, process group\n"
1401 "or user, as indicated by @var{which} and @var{who}. @var{which}\n"
1402 "is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP}\n"
1403 "or @code{PRIO_USER}, and @var{who} is interpreted relative to\n"
1404 "@var{which} (a process identifier for @code{PRIO_PROCESS},\n"
1405 "process group identifier for @code{PRIO_PGRP}, and a user\n"
1406 "identifier for @code{PRIO_USER}. A zero value of @var{who}\n"
1407 "denotes the current process, process group, or user. Return\n"
1408 "the highest priority (lowest numerical value) of any of the\n"
1409 "specified processes.")
1410 #define FUNC_NAME s_scm_getpriority
1412 int cwhich
, cwho
, ret
;
1414 SCM_VALIDATE_INUM_COPY (1, which
, cwhich
);
1415 SCM_VALIDATE_INUM_COPY (2, who
, cwho
);
1417 /* We have to clear errno and examine it later, because -1 is a
1418 legal return value for getpriority(). */
1420 ret
= getpriority (cwhich
, cwho
);
1423 return SCM_MAKINUM (ret
);
1426 #endif /* HAVE_GETPRIORITY */
1428 #if HAVE_SETPRIORITY
1429 SCM_DEFINE (scm_setpriority
, "setpriority", 3, 0, 0,
1430 (SCM which
, SCM who
, SCM prio
),
1431 "Set the scheduling priority of the process, process group\n"
1432 "or user, as indicated by @var{which} and @var{who}. @var{which}\n"
1433 "is one of the variables @code{PRIO_PROCESS}, @code{PRIO_PGRP}\n"
1434 "or @code{PRIO_USER}, and @var{who} is interpreted relative to\n"
1435 "@var{which} (a process identifier for @code{PRIO_PROCESS},\n"
1436 "process group identifier for @code{PRIO_PGRP}, and a user\n"
1437 "identifier for @code{PRIO_USER}. A zero value of @var{who}\n"
1438 "denotes the current process, process group, or user.\n"
1439 "@var{prio} is a value in the range -20 and 20, the default\n"
1440 "priority is 0; lower priorities cause more favorable\n"
1441 "scheduling. Sets the priority of all of the specified\n"
1442 "processes. Only the super-user may lower priorities.\n"
1443 "The return value is not specified.")
1444 #define FUNC_NAME s_scm_setpriority
1446 int cwhich
, cwho
, cprio
;
1448 SCM_VALIDATE_INUM_COPY (1, which
, cwhich
);
1449 SCM_VALIDATE_INUM_COPY (2, who
, cwho
);
1450 SCM_VALIDATE_INUM_COPY (3, prio
, cprio
);
1452 if (setpriority (cwhich
, cwho
, cprio
) == -1)
1454 return SCM_UNSPECIFIED
;
1457 #endif /* HAVE_SETPRIORITY */
1460 SCM_DEFINE (scm_getpass
, "getpass", 1, 0, 0,
1462 "Display @var{prompt} to the standard error output and read\n"
1463 "a password from @file{/dev/tty}. If this file is not\n"
1464 "accessible, it reads from standard input. The password may be\n"
1465 "up to 127 characters in length. Additional characters and the\n"
1466 "terminating newline character are discarded. While reading\n"
1467 "the password, echoing and the generation of signals by special\n"
1468 "characters is disabled.")
1469 #define FUNC_NAME s_scm_getpass
1474 SCM_VALIDATE_STRING (1, prompt
);
1476 p
= getpass(SCM_STRING_CHARS (prompt
));
1477 passwd
= scm_makfrom0str (p
);
1479 /* Clear out the password in the static buffer. */
1480 memset (p
, 0, strlen (p
));
1485 #endif /* HAVE_GETPASS */
1487 /* Wrapper function for flock() support under M$-Windows. */
1490 # include <sys/locking.h>
1493 /* Current MinGW package fails to define this. *sigh* */
1494 # define _LK_UNLCK 0
1501 static int flock (int fd
, int operation
)
1506 /* Disable invalid arguments. */
1507 if (((operation
& (LOCK_EX
| LOCK_SH
)) == (LOCK_EX
| LOCK_SH
)) ||
1508 ((operation
& (LOCK_EX
| LOCK_UN
)) == (LOCK_EX
| LOCK_UN
)) ||
1509 ((operation
& (LOCK_SH
| LOCK_UN
)) == (LOCK_SH
| LOCK_UN
)))
1515 /* Determine mode of operation and discard unsupported ones. */
1516 if (operation
== (LOCK_NB
| LOCK_EX
))
1517 operation
= _LK_NBLCK
;
1518 else if (operation
& LOCK_UN
)
1519 operation
= _LK_UNLCK
;
1520 else if (operation
== LOCK_EX
)
1521 operation
= _LK_LOCK
;
1528 /* Save current file pointer and seek to beginning. */
1529 if ((pos
= lseek (fd
, 0, SEEK_CUR
)) == -1 || (len
= filelength (fd
)) == -1)
1531 lseek (fd
, 0L, SEEK_SET
);
1533 /* Deadlock if necessary. */
1536 ret
= _locking (fd
, operation
, len
);
1538 while (ret
== -1 && errno
== EDEADLOCK
);
1540 /* Produce meaningful error message. */
1541 if (errno
== EACCES
&& operation
== _LK_NBLCK
)
1546 /* Return to saved file position pointer. */
1547 lseek (fd
, pos
, SEEK_SET
);
1551 #endif /* __MINGW32__ */
1553 #if HAVE_FLOCK || defined (__MINGW32__)
1554 SCM_DEFINE (scm_flock
, "flock", 2, 0, 0,
1555 (SCM file
, SCM operation
),
1556 "Apply or remove an advisory lock on an open file.\n"
1557 "@var{operation} specifies the action to be done:\n"
1560 "Shared lock. More than one process may hold a shared lock\n"
1561 "for a given file at a given time.\n"
1563 "Exclusive lock. Only one process may hold an exclusive lock\n"
1564 "for a given file at a given time.\n"
1566 "Unlock the file.\n"
1568 "Don't block when locking. May be specified by bitwise OR'ing\n"
1569 "it to one of the other operations.\n"
1571 "The return value is not specified. @var{file} may be an open\n"
1572 "file descriptor or an open file descriptor port.")
1573 #define FUNC_NAME s_scm_flock
1575 int coperation
, fdes
;
1577 if (SCM_INUMP (file
))
1578 fdes
= SCM_INUM (file
);
1581 SCM_VALIDATE_OPFPORT (2, file
);
1583 fdes
= SCM_FPORT_FDES (file
);
1585 SCM_VALIDATE_INUM_COPY (2, operation
, coperation
);
1586 if (flock (fdes
, coperation
) == -1)
1588 return SCM_UNSPECIFIED
;
1591 #endif /* HAVE_FLOCK */
1593 #if HAVE_SETHOSTNAME
1594 SCM_DEFINE (scm_sethostname
, "sethostname", 1, 0, 0,
1596 "Set the host name of the current processor to @var{name}. May\n"
1597 "only be used by the superuser. The return value is not\n"
1599 #define FUNC_NAME s_scm_sethostname
1601 SCM_VALIDATE_STRING (1, name
);
1603 if (sethostname (SCM_STRING_CHARS (name
), SCM_STRING_LENGTH (name
)) == -1)
1605 return SCM_UNSPECIFIED
;
1608 #endif /* HAVE_SETHOSTNAME */
1610 #if HAVE_GETHOSTNAME
1611 SCM_DEFINE (scm_gethostname
, "gethostname", 0, 0, 0,
1613 "Return the host name of the current processor.")
1614 #define FUNC_NAME s_scm_gethostname
1616 /* 256 is for Solaris, under Linux ENAMETOOLONG is returned if not
1619 char *p
= scm_malloc (len
);
1622 res
= gethostname (p
, len
);
1623 while (res
== -1 && errno
== ENAMETOOLONG
)
1625 p
= scm_realloc (p
, len
* 2);
1627 res
= gethostname (p
, len
);
1634 name
= scm_makfrom0str (p
);
1639 #endif /* HAVE_GETHOSTNAME */
1644 scm_add_feature ("posix");
1646 scm_add_feature ("EIDs");
1649 scm_c_define ("WAIT_ANY", SCM_MAKINUM (WAIT_ANY
));
1652 scm_c_define ("WAIT_MYPGRP", SCM_MAKINUM (WAIT_MYPGRP
));
1655 scm_c_define ("WNOHANG", SCM_MAKINUM (WNOHANG
));
1658 scm_c_define ("WUNTRACED", SCM_MAKINUM (WUNTRACED
));
1661 /* access() symbols. */
1662 scm_c_define ("R_OK", SCM_MAKINUM (R_OK
));
1663 scm_c_define ("W_OK", SCM_MAKINUM (W_OK
));
1664 scm_c_define ("X_OK", SCM_MAKINUM (X_OK
));
1665 scm_c_define ("F_OK", SCM_MAKINUM (F_OK
));
1668 scm_c_define ("LC_COLLATE", SCM_MAKINUM (LC_COLLATE
));
1671 scm_c_define ("LC_CTYPE", SCM_MAKINUM (LC_CTYPE
));
1674 scm_c_define ("LC_MONETARY", SCM_MAKINUM (LC_MONETARY
));
1677 scm_c_define ("LC_NUMERIC", SCM_MAKINUM (LC_NUMERIC
));
1680 scm_c_define ("LC_TIME", SCM_MAKINUM (LC_TIME
));
1683 scm_c_define ("LC_MESSAGES", SCM_MAKINUM (LC_MESSAGES
));
1686 scm_c_define ("LC_ALL", SCM_MAKINUM (LC_ALL
));
1689 scm_c_define ("PIPE_BUF", scm_long2num (PIPE_BUF
));
1693 scm_c_define ("PRIO_PROCESS", SCM_MAKINUM (PRIO_PROCESS
));
1696 scm_c_define ("PRIO_PGRP", SCM_MAKINUM (PRIO_PGRP
));
1699 scm_c_define ("PRIO_USER", SCM_MAKINUM (PRIO_USER
));
1703 scm_c_define ("LOCK_SH", SCM_MAKINUM (LOCK_SH
));
1706 scm_c_define ("LOCK_EX", SCM_MAKINUM (LOCK_EX
));
1709 scm_c_define ("LOCK_UN", SCM_MAKINUM (LOCK_UN
));
1712 scm_c_define ("LOCK_NB", SCM_MAKINUM (LOCK_NB
));
1715 #include "libguile/cpp_sig_symbols.c"
1716 #include "libguile/posix.x"