diff options
Diffstat (limited to 'builtins.c')
| -rw-r--r-- | builtins.c | 44 |
1 files changed, 25 insertions, 19 deletions
@@ -7,16 +7,17 @@ because of a bad umask. */ -#include "rc.h" - #include <sys/ioctl.h> #include <setjmp.h> #include <errno.h> - +#include "rc.h" #include "jbwrap.h" #include "sigmsgs.h" +#ifndef NOLIMITS +#include <sys/time.h> +#include <sys/resource.h> +#endif #include "addon.h" -#include "rlimit.h" extern int umask(int); @@ -24,11 +25,10 @@ static void b_break(char **), b_cd(char **), b_eval(char **), b_exit(char **), b_newpgrp(char **), b_return(char **), b_shift(char **), b_umask(char **), b_wait(char **), b_whatis(char **); -#if HAVE_SETRLIMIT +#ifndef NOLIMITS static void b_limit(char **); #endif - -#if RC_ECHO +#ifndef NOECHO static void b_echo(char **); #endif @@ -39,13 +39,13 @@ static struct { { b_break, "break" }, { b_builtin, "builtin" }, { b_cd, "cd" }, -#if RC_ECHO +#ifndef NOECHO { b_echo, "echo" }, #endif { b_eval, "eval" }, { b_exec, "exec" }, { b_exit, "exit" }, -#if HAVE_SETRLIMIT +#ifndef NOLIMITS { b_limit, "limit" }, #endif { b_newpgrp, "newpgrp" }, @@ -100,7 +100,7 @@ static void badnum(char *num) { extern void b_exec(char **av) { } -#if RC_ECHO +#ifndef NOECHO /* echo -n omits a newline. echo -- -n echos '-n' */ static void b_echo(char **av) { @@ -121,7 +121,7 @@ static void b_echo(char **av) { static void b_cd(char **av) { List *s, nil; char *path = NULL; - size_t t, pathlen = 0; + SIZE_T t, pathlen = 0; if (*++av == NULL) { s = varlookup("home"); *av = (s == NULL) ? "/" : s->w; @@ -250,8 +250,7 @@ extern void b_builtin(char **av) { /* wait for a given process, or all outstanding processes */ static void b_wait(char **av) { - int stat; - pid_t pid; + int stat, pid; if (av[1] == NULL) { waitforall(); return; @@ -415,13 +414,15 @@ static void b_newpgrp(char **av) { arg_count("newpgrp"); return; } - setpgid(rc_pid, rc_pid); /* XXX check return value */ - tcsetpgrp(2, rc_pid); /* XXX check return value */ + setpgrp(rc_pid, rc_pid); +#ifdef TIOCSPGRP + ioctl(2, TIOCSPGRP, &rc_pid); +#endif } /* Berkeley limit support was cleaned up by Paul Haahr. */ -#if HAVE_SETRLIMIT +#ifndef NOLIMITS typedef struct Suffix Suffix; struct Suffix { const Suffix *next; @@ -463,9 +464,14 @@ static const Limit limits[] = { { NULL, 0, NULL } }; +#ifndef SYSVR4 +extern int getrlimit(int, struct rlimit *); +extern int setrlimit(int, struct rlimit *); +#endif + static void printlimit(const Limit *limit, bool hard) { struct rlimit rlim; - rlim_t lim; + long lim; getrlimit(limit->flag, &rlim); if (hard) lim = rlim.rlim_max; @@ -480,11 +486,11 @@ static void printlimit(const Limit *limit, bool hard) { lim /= suf->amount; break; } - fprint(1, RLIM_FMT, limit->name, (RLIM_CONV)lim, (suf == NULL || lim == 0) ? "" : suf->name); + fprint(1, "%s \t%d%s\n", limit->name, lim, (suf == NULL || lim == 0) ? "" : suf->name); } } -static rlim_t parselimit(const Limit *limit, char *s) { +static long parselimit(const Limit *limit, char *s) { char *t; int len = strlen(s); long lim = 1; |