summaryrefslogtreecommitdiffstats
path: root/posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'posix.c')
-rw-r--r--posix.c43
1 files changed, 18 insertions, 25 deletions
diff --git a/posix.c b/posix.c
index 77cfaf4..1ed5f1c 100644
--- a/posix.c
+++ b/posix.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1995, 1998 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -57,6 +57,10 @@
#else /* added by Denys Duchier */
# ifdef SVR4
# include <unistd.h>
+# else
+# ifdef linux
+# include <unistd.h>
+# endif
# endif
#endif
@@ -134,16 +138,6 @@ SCM open_pipe(pipestr, modes)
ALLOW_INTS;
return z;
}
-SCM l_open_input_pipe(pipestr)
- SCM pipestr;
-{
- return open_pipe(pipestr, makfromstr("r", (sizeof "r")-1));
-}
-SCM l_open_output_pipe(pipestr)
- SCM pipestr;
-{
- return open_pipe(pipestr, makfromstr("w", (sizeof "w")-1));
-}
static int prinpipe(exp, port, writing)
SCM exp; SCM port; int writing;
{
@@ -155,25 +149,22 @@ static char scm_s_getgroups[] = "getgroups";
SCM scm_getgroups()
{
SCM grps, ans;
- int ngroups = getgroups(NULL, 0);
+ int ngroups = getgroups(0, 0);
if (!ngroups) return BOOL_F;
NEWCELL(grps);
DEFER_INTS;
+ /* grps is used as a gc protect, its type used to be tc7_string, but
+ strings are now checked for null termination during gc. */
+ grps = must_malloc_cell(ngroups * sizeof(gid_t), scm_s_getgroups);
+ /* length need not be exactly right */
+ SETLENGTH(grps, (0L + ngroups * sizeof(gid_t))/sizeof(long), tc7_uvect);
+ ALLOW_INTS;
{
- gid_t *groups = (gid_t *)must_malloc(ngroups * sizeof(gid_t),
- scm_s_getgroups);
+ gid_t *groups = (gid_t *)CHARS(grps);
int val = getgroups(ngroups, groups);
- if (val < 0) {
- must_free((char *)groups);
- ALLOW_INTS;
- return BOOL_F;
- }
- SETCHARS(grps, groups); /* set up grps as a GC protect */
- SETLENGTH(grps, 0L + ngroups * sizeof(gid_t), tc7_string);
- ALLOW_INTS;
+ if (val < 0) return BOOL_F;
ans = make_vector(MAKINUM(ngroups), UNDEFINED);
while (--ngroups >= 0) VELTS(ans)[ngroups] = MAKINUM(groups[ngroups]);
- SETCHARS(grps, groups); /* to make sure grps stays around. */
return ans;
}
}
@@ -383,8 +374,6 @@ static iproc subr1s[] = {
{"setegid", l_setegid},
{"seteuid", l_seteuid},
#endif
- {"open-input-pipe", l_open_input_pipe},
- {"open-output-pipe", l_open_output_pipe},
{s_ttyname, l_ttyname},
{0, 0}};
@@ -411,4 +400,8 @@ void init_posix()
ptobs[0x0ff & (tc16_pipe>>8)].free = pclose;
ptobs[0x0ff & (tc16_pipe>>8)].print = prinpipe;
add_feature(s_pipe);
+ scm_ldstr("\n\
+(define (open-input-pipe cmd) (open-pipe cmd \"r\"))\n\
+(define (open-output-pipe cmd) (open-pipe cmd \"w\"))\n\
+");
}