develooper Front page | perl.perl5.porters | Postings from April 2003

[PATCH] all about the recent standard conforming glibc's nice

Thread Next
Enache Adrian
April 23, 2003 07:39
[PATCH] all about the recent standard conforming glibc's nice
Message ID:
On Tue, Apr 22, 2003 at 10:11:12PM +0200, Tels wrote:
> the author expected. However, does not mention the return values,
> but "man setgid" does. Should this be documented, or is this something
> different on each system? (You can tell I have not the slightest clue about

shouldn't be!

from susv3's functions/setgid.html:


     Upon  successful  completion, 0 is returned. Otherwise, -1 shall be
     returned and errno set to indicate the error.

In, all those system functsions have a return value of SysRet;
if the author of Net::Server expect them to return undef in case of failure,
he's probably right: look at lib/ExtUtils/typemap for T_SYSRET and
at the generated POSIX.c.

And now, about nice: 

       nice    This is similar to the C function "nice()", for changing the
               scheduling preference of the current process.  Positive argu-
               ments mean more polite process, negative values more needy pro-
               cess.  Normal user processes can only be more polite.

               Returns "undef" on failure.

# perl -MPOSIX=nice -le 'print nice -1'


I am root and I set my nice value to -1 on linux (glibc 2.2.93).

That's because the newer glibc's follow the standard and return the
new nice value ( which could be -1 ) instead of zero in case of success:
[ That broke a lot of programs on linux - most notably vmware ]

from susv3's functions/nice.html:

     As  -1  is a permissible return value in a successful situation, an
     application  wishing to check for error situations should set errno
     to  0, then call nice(), and if it returns -1, check to see whether
     errno is non-zero.


     Upon  successful completion, nice() shall return the new nice value
     -{NZERO}.  Otherwise, -1 shall be returned, the process' nice value
     shall not be changed, and errno shall be set to indicate the error.


--- /arc/bleadperl/ext/POSIX/POSIX.xs	2002-12-18 05:20:13.000000000 +0200
+++ perl/ext/POSIX/POSIX.xs	2003-04-23 17:35:17.000000000 +0300
@@ -1386,9 +1386,13 @@ lseek(fd, offset, whence)
+SV *
 	int		incr
+    PPCODE:
+	errno = 0;
+	if ((incr = nice(incr)) != -1 || errno == 0)
+	    XPUSHs(sv_2mortal(newSViv(incr)));

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About