more errno cleanup

This commit is contained in:
tg 2007-06-06 23:41:24 +00:00
parent 3dcf22a319
commit 81014fa81b
2 changed files with 8 additions and 6 deletions

View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.56 2007/06/06 23:28:15 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.57 2007/06/06 23:41:23 tg Exp $");
int int
c_cd(const char **wp) c_cd(const char **wp)
@ -3008,11 +3008,12 @@ c_ulimit(const char **wp)
if (how & HARD) if (how & HARD)
limit.rlim_max = val; limit.rlim_max = val;
if (setrlimit(l->scmd, &limit) < 0) { if (setrlimit(l->scmd, &limit) < 0) {
if (errno == EPERM) how = errno;
if (how == EPERM)
bi_errorf("exceeds allowable limit"); bi_errorf("exceeds allowable limit");
else else
bi_errorf("bad limit: %s", bi_errorf("bad limit: %s",
strerror(errno)); strerror(how));
return 1; return 1;
} }
} else { } else {

7
jobs.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.23 2007/06/06 23:28:15 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.24 2007/06/06 23:41:24 tg Exp $");
/* Order important! */ /* Order important! */
#define PRUNNING 0 #define PRUNNING 0
@ -649,6 +649,7 @@ j_resume(const char *cp, int bg)
if (ttypgrp_ok && if (ttypgrp_ok &&
tcsetpgrp(tty_fd, (j->flags & JF_SAVEDTTYPGRP) ? tcsetpgrp(tty_fd, (j->flags & JF_SAVEDTTYPGRP) ?
j->saved_ttypgrp : j->pgrp) < 0) { j->saved_ttypgrp : j->pgrp) < 0) {
rv = errno;
if (j->flags & JF_SAVEDTTY) if (j->flags & JF_SAVEDTTY)
tcsetattr(tty_fd, TCSADRAIN, &tty_state); tcsetattr(tty_fd, TCSADRAIN, &tty_state);
sigprocmask(SIG_SETMASK, &omask, sigprocmask(SIG_SETMASK, &omask,
@ -657,7 +658,7 @@ j_resume(const char *cp, int bg)
tty_fd, tty_fd,
(int) ((j->flags & JF_SAVEDTTYPGRP) ? (int) ((j->flags & JF_SAVEDTTYPGRP) ?
j->saved_ttypgrp : j->pgrp), j->saved_ttypgrp : j->pgrp),
strerror(errno)); strerror(rv));
return 1; return 1;
} }
} }
@ -668,7 +669,7 @@ j_resume(const char *cp, int bg)
} }
if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) < 0) { if (j->state == PRUNNING && killpg(j->pgrp, SIGCONT) < 0) {
int err = errno; int err = errno;
if (!bg) { if (!bg) {
j->flags &= ~JF_FG; j->flags &= ~JF_FG;