Hugh McIntyre wrote:
> Roland Mainz wrote:
> > [EMAIL PROTECTED] wrote:
> >>> Is it safe to call setrlimit(RLIMIT_NOFILE, ..) from a library?
> >>> The code does
> >>>        if (getrlimit(RLIMIT_NOFILE, &rl) == 0) {
> >>>                rl.rlim_cur = rl.rlim_max;
> >>>                (void) setrlimit(RLIMIT_NOFILE, &rl);
> >>>        }
> >> No.  Libraries should not have side effects like this.
> >
> > Erm... depends on the type of library. libshell (which is ksh93 provided
> > as a shell) can generate such side-effects if someone uses the "ulimit"
> > builtin command.
> 
> If you invoke a "ulimit" command, then changing RLIMITs is not a
> side-effect.  Instead it's the main intended result.  Cases with
> side-effects are different, IMHO at least.

Right... but sometimes it may still be suprising, for example if you
have some kind of callback which uses "ulimit" and then causes trouble
for the rest of the code. We've seen that with "ulimit" in a dtksh
widget callback function where someone used "ulimit" in a "( code ;
ulimit set-something ; more code )"-construct and assumed that at the
end of the ")" the shell resets the ulimit values. Unfortunately in some
rare cases Solaris's dtksh doesn't do that (which is not really
suprising since Solaris dtksh uses an ancient alpha version of ksh93
version 'd'... grumpf... ;-( ).

> PS: Provided libshell only changes the intended limit, of course.

Right...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) [EMAIL PROTECTED]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to