o rename ulimit -p into ulimit -u, so we are in agreement with bash

o fix brokeness for 1>&5 redirection, where `5' was an invalid file
  descriptor, but no error message has been generated

o fix brokeness for redirect to/from myself case
This commit is contained in:
Joerg Wunsch 1995-10-21 00:47:32 +00:00
parent 263f40b52b
commit 769bbc65e8
3 changed files with 12 additions and 7 deletions

View File

@ -34,7 +34,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: miscbltin.c,v 1.2 1994/09/24 02:57:52 davidg Exp $
* $Id: miscbltin.c,v 1.3 1995/10/19 18:42:10 joerg Exp $
*/
#ifndef lint
@ -209,7 +209,7 @@ static struct restab restab[] = {
{RLIMIT_FSIZE, 512, "filesize(512-blocks) "},
{RLIMIT_MEMLOCK, 1024, "lockedmem(kilobytes) "},
{RLIMIT_NOFILE, 1, "nofiles(descriptors) "},
{RLIMIT_NPROC, 1, "processes(max) "},
{RLIMIT_NPROC, 1, "userprocs(max) "},
{RLIMIT_RSS, 1024, "memoryuse(kilobytes) "},
{RLIMIT_STACK, 1024, "stacksize(kilobytes) "}
};
@ -265,7 +265,7 @@ ulimitcmd(argc, argv) char **argv; {
opterr = 0; /* use own error processing */
optreset = 1;
optind = 1;
while ((i = getopt(argc, argv, "HSacdfnstmlp")) != EOF) {
while ((i = getopt(argc, argv, "HSacdfnstmlu")) != EOF) {
arg++;
switch(i) {
case 'H':
@ -313,7 +313,7 @@ ulimitcmd(argc, argv) char **argv; {
if(resource != RLIMIT_UNSPEC) errs++;
resource = RLIMIT_MEMLOCK;
break;
case 'p':
case 'u':
if(resource != RLIMIT_UNSPEC) errs++;
resource = RLIMIT_NPROC;
break;

View File

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: redir.c,v 1.2 1994/09/24 02:58:10 davidg Exp $
* $Id: redir.c,v 1.3 1995/05/30 00:07:22 rgrimes Exp $
*/
#ifndef lint
@ -120,6 +120,9 @@ redirect(redir, flags)
}
for (n = redir ; n ; n = n->nfile.next) {
fd = n->nfile.fd;
if ((n->nfile.type == NTOFD || n->nfile.type == NFROMFD) &&
n->ndup.dupfd == fd)
continue; /* redirect from/to myself */
if ((flags & REDIR_PUSH) && sv->renamed[fd] == EMPTY) {
INTOFF;
if ((i = copyfd(fd, 10)) != EMPTY) {
@ -341,5 +344,7 @@ copyfd(from, to) {
newfd = fcntl(from, F_DUPFD, to);
if (newfd < 0 && errno == EMFILE)
return EMPTY;
if (newfd < 0)
error("%d: %s", from, strerror(errno));
return newfd;
}

View File

@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)sh.1 8.4 (Berkeley) 4/18/94
.\" $Id: sh.1,v 1.3 1995/05/05 16:49:15 adam Exp $
.\" $Id: sh.1,v 1.4 1995/10/19 18:42:12 joerg Exp $
.\"
.\"
.\"
@ -1319,7 +1319,7 @@ The maximal resident set size of a process, in kilobytes.
-n nofiles
The maximal number of descriptors that could be opened by a process.
.TP 2
-p procmax
-u userproc
The maximal number of simultaneous processes for this user ID.
.TP 2
-s stacksize