Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getpriority and setpriority are underdocumented #16128

Closed
p5pRT opened this issue Aug 28, 2017 · 17 comments
Closed

getpriority and setpriority are underdocumented #16128

p5pRT opened this issue Aug 28, 2017 · 17 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 28, 2017

Migrated from rt.perl.org#131982 (status was 'resolved')

Searchable as RT131982$

@p5pRT
Copy link
Author

p5pRT commented Aug 28, 2017

From @eserte

This is a bug report for perl from slaven@​rezic.de,
generated with the help of perlbug 1.40 running under perl 5.24.1.


"perldoc -f getpriority" just refers to the getpriority manpage
for the details. This is not ideal, and the manpage only mentions
the PRIO_{PROCESS,PGRP,USER} macros as possible values for the
WHICH parameter. So to find the actual values one has to look
around in include files, or write a small C program printing out
these values.

On Linux and FreeBSD systems the values are​:
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2
Maybe the situation is similar with the SEEK_{SET,CUR,END}
constants and the values are everywhere the same, and may be
documented in perlfunc.pod? And maybe the documentation could
point to BSD​::Resource which also implements getpriority &
setpriority, but also defines the PRIO_* constants.



Flags​:
  category=docs
  severity=low


This perlbug was built using Perl 5.20.2 - Sat Jun 3 12​:27​:58 UTC 2017
It is being executed now by Perl 5.24.1 - Sun Jan 15 18​:20​:36 CET 2017.

Site configuration information for perl 5.24.1​:

Configured by eserte at Sun Jan 15 18​:20​:36 CET 2017.

Summary of my perl5 (revision 5 version 24 subversion 1) configuration​:
 
  Platform​:
  osname=linux, osvers=3.16.0-4-amd64, archname=x86_64-linux
  uname='linux cabulja 3.16.0-4-amd64 #1 smp debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 gnulinux '
  config_args='-ds -e -Dprefix=/opt/perl-5.24.1 -Dcf_email=srezic@​cpan.org'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  use64bitint=define, use64bitall=define, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
  optimize='-O2',
  cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
  ccversion='', gccversion='4.9.2', gccosandvers=''
  intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
  ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -fstack-protector-strong -L/usr/local/lib'
  libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
  libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
  perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
  libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.19'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'


@​INC for perl 5.24.1​:
  /opt/perl-5.24.1/lib/site_perl/5.24.1/x86_64-linux
  /opt/perl-5.24.1/lib/site_perl/5.24.1
  /opt/perl-5.24.1/lib/5.24.1/x86_64-linux
  /opt/perl-5.24.1/lib/5.24.1


Environment for perl 5.24.1​:
  HOME=/home/eserte
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/local/bin​:/usr/bin​:/bin​:/usr/local/sbin​:/usr/sbin​:/sbin​:/home/eserte/bin/linux-gnu​:/home/eserte/bin/sh​:/home/eserte/bin​:/home/eserte/bin/pistachio-perl/bin​:/usr/games​:/home/eserte/devel
  PERLDOC=-MPod​::Perldoc​::ToTextOverstrike
  PERL_BADLANG (unset)
  SHELL=/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Aug 29, 2017

From @jkeenan

On Mon, 28 Aug 2017 19​:53​:52 GMT, slaven@​rezic.de wrote​:

This is a bug report for perl from slaven@​rezic.de,
generated with the help of perlbug 1.40 running under perl 5.24.1.

-----------------------------------------------------------------
"perldoc -f getpriority" just refers to the getpriority manpage
for the details. This is not ideal, and the manpage only mentions
the PRIO_{PROCESS,PGRP,USER} macros as possible values for the
WHICH parameter. So to find the actual values one has to look
around in include files, or write a small C program printing out
these values.

On Linux and FreeBSD systems the values are​:
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2
Maybe the situation is similar with the SEEK_{SET,CUR,END}
constants and the values are everywhere the same, and may be
documented in perlfunc.pod? And maybe the documentation could
point to BSD​::Resource which also implements getpriority &
setpriority, but also defines the PRIO_* constants.

Underdocumented ... and apparently undertested as well -- as inspection of results from the following will show​:

#####
ack '(get|set)priority' ./t
#####


---
Flags​:
category=docs
severity=low
---
This perlbug was built using Perl 5.20.2 - Sat Jun 3 12​:27​:58 UTC
2017
It is being executed now by Perl 5.24.1 - Sun Jan 15 18​:20​:36 CET
2017.

Site configuration information for perl 5.24.1​:

Configured by eserte at Sun Jan 15 18​:20​:36 CET 2017.

Summary of my perl5 (revision 5 version 24 subversion 1)
configuration​:

Platform​:
osname=linux, osvers=3.16.0-4-amd64, archname=x86_64-linux
uname='linux cabulja 3.16.0-4-amd64 #1 smp debian 3.16.36-1+deb8u1
(2016-09-03) x86_64 gnulinux '
config_args='-ds -e -Dprefix=/opt/perl-5.24.1
-Dcf_email=srezic@​cpan.org'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler​:
cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-
protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
optimize='-O2',
cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-
strong -I/usr/local/include'
ccversion='', gccversion='4.9.2', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678,
doublekind=3
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16,
longdblkind=3
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries​:
ld='cc', ldflags =' -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.9/include-
fixed /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu
/lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
libs=-lpthread -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
-lgdbm_compat
perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
libc=libc-2.19.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.19'
Dynamic Linking​:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-
protector-strong'

---
@​INC for perl 5.24.1​:
/opt/perl-5.24.1/lib/site_perl/5.24.1/x86_64-linux
/opt/perl-5.24.1/lib/site_perl/5.24.1
/opt/perl-5.24.1/lib/5.24.1/x86_64-linux
/opt/perl-5.24.1/lib/5.24.1

---
Environment for perl 5.24.1​:
HOME=/home/eserte
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin​:/usr/bin​:/bin​:/usr/local/sbin​:/usr/sbin​:/sbin​:/home/eserte/bin/linux-
gnu​:/home/eserte/bin/sh​:/home/eserte/bin​:/home/eserte/bin/pistachio-
perl/bin​:/usr/games​:/home/eserte/devel
PERLDOC=-MPod​::Perldoc​::ToTextOverstrike
PERL_BADLANG (unset)
SHELL=/bin/zsh

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Aug 29, 2017

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Sep 2, 2017

From @jkeenan

On Mon, 28 Aug 2017 19​:53​:52 GMT, slaven@​rezic.de wrote​:

This is a bug report for perl from slaven@​rezic.de,
generated with the help of perlbug 1.40 running under perl 5.24.1.

-----------------------------------------------------------------
"perldoc -f getpriority" just refers to the getpriority manpage
for the details. This is not ideal, and the manpage only mentions
the PRIO_{PROCESS,PGRP,USER} macros as possible values for the
WHICH parameter. So to find the actual values one has to look
around in include files, or write a small C program printing out
these values.

On Linux and FreeBSD systems the values are​:
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2

POSIX (assuming http​://pubs.opengroup.org/onlinepubs/007908799/xsh/sysresource.h.html is an accurate representation of POSIX) doesn't require that 0, 1 and 2 be the specific values of these three constants. It merely requires that they be defined​:

#####
The <sys/resource.h> header defines the following symbolic constants as possible values of the which argument of getpriority() and setpriority()​:

PRIO_PROCESS
  Identifies who argument as a process ID.
PRIO_PGRP
  Identifies who argument as a process group ID.
PRIO_USER
  Identifies who argument as a user ID.
#####

If that's the case, then I don't think the Perl documentation should say anything about specific values.

Maybe the situation is similar with the SEEK_{SET,CUR,END}
constants and the values are everywhere the same,

I don't think the situation is analogous to SEEK_*. Perl explicitly defines those three constants if they are not already defined​:

#####
perlio.h
152​:#ifndef SEEK_SET
153​:#define SEEK_SET 0
156​:#ifndef SEEK_CUR
157​:#define SEEK_CUR 1
160​:#ifndef SEEK_END
161​:#define SEEK_END 2
#####

AFAICT, Perl makes no attempt to provide values for those constants if they are not already defined.

and may be
documented in perlfunc.pod? And maybe the documentation could
point to BSD​::Resource which also implements getpriority &
setpriority, but also defines the PRIO_* constants.

I don't object to mentioning CPAN modules in Perl 5 documentation, but, other things being equal, I think we should only refer to CPAN modules if they are well known and widely used. BSD​::Resource is Jarkko code, so I have no doubt as to its quality. But I was unaware of it until reading this RT and have never had occasion to use it.

Thank you very much.
--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Sep 4, 2017

From @tonycoz

On Sat, 02 Sep 2017 16​:11​:22 -0700, jkeenan wrote​:

On Mon, 28 Aug 2017 19​:53​:52 GMT, slaven@​rezic.de wrote​:

This is a bug report for perl from slaven@​rezic.de,
generated with the help of perlbug 1.40 running under perl 5.24.1.

-----------------------------------------------------------------
"perldoc -f getpriority" just refers to the getpriority manpage
for the details. This is not ideal, and the manpage only mentions
the PRIO_{PROCESS,PGRP,USER} macros as possible values for the
WHICH parameter. So to find the actual values one has to look
around in include files, or write a small C program printing out
these values.

On Linux and FreeBSD systems the values are​:
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2

POSIX (assuming
http​://pubs.opengroup.org/onlinepubs/007908799/xsh/sysresource.h.html
is an accurate representation of POSIX) doesn't require that 0, 1 and
2 be the specific values of these three constants. It merely requires
that they be defined​:

#####
The <sys/resource.h> header defines the following symbolic constants
as possible values of the which argument of getpriority() and
setpriority()​:

PRIO_PROCESS
Identifies who argument as a process ID.
PRIO_PGRP
Identifies who argument as a process group ID.
PRIO_USER
Identifies who argument as a user ID.
#####

If that's the case, then I don't think the Perl documentation should
say anything about specific values.

I agree.

Maybe the situation is similar with the SEEK_{SET,CUR,END}
constants and the values are everywhere the same,

I don't think the situation is analogous to SEEK_*. Perl explicitly
defines those three constants if they are not already defined​:

#####
perlio.h
152​:#ifndef SEEK_SET
153​:#define SEEK_SET 0
156​:#ifndef SEEK_CUR
157​:#define SEEK_CUR 1
160​:#ifndef SEEK_END
161​:#define SEEK_END 2
#####

AFAICT, Perl makes no attempt to provide values for those constants if
they are not already defined.

Fcntl provides default values for the SEEK_* constants - see ext/Fcntl/Makefile.PL

and may be
documented in perlfunc.pod? And maybe the documentation could
point to BSD​::Resource which also implements getpriority &
setpriority, but also defines the PRIO_* constants.

I don't object to mentioning CPAN modules in Perl 5 documentation,
but, other things being equal, I think we should only refer to CPAN
modules if they are well known and widely used. BSD​::Resource is
Jarkko code, so I have no doubt as to its quality. But I was unaware
of it until reading this RT and have never had occasion to use it.

I'd heard of it, but never used it. I've never used (get|set)priority() in core.

I can see three solutions​:

1) add the constants to Fcntl - except these constants aren't defined by fcntl.h, so they don't really belong.

2) create a new core module Sys​::Resource (to match <sys/resource.h>, which defines the constants. Of course this duplicates the work BSD​::Resource already does better.

3) link to BSD​::Resource

Out of these 3) seems the most palatable.

Tony

@p5pRT
Copy link
Author

p5pRT commented Sep 4, 2017

From @xsawyerx

On 09/04/2017 07​:00 AM, Tony Cook via RT wrote​:

On Sat, 02 Sep 2017 16​:11​:22 -0700, jkeenan wrote​:

On Mon, 28 Aug 2017 19​:53​:52 GMT, slaven@​rezic.de wrote​:

This is a bug report for perl from slaven@​rezic.de,
generated with the help of perlbug 1.40 running under perl 5.24.1.

-----------------------------------------------------------------
"perldoc -f getpriority" just refers to the getpriority manpage
for the details. This is not ideal, and the manpage only mentions
the PRIO_{PROCESS,PGRP,USER} macros as possible values for the
WHICH parameter. So to find the actual values one has to look
around in include files, or write a small C program printing out
these values.

On Linux and FreeBSD systems the values are​:
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2
POSIX (assuming
http​://pubs.opengroup.org/onlinepubs/007908799/xsh/sysresource.h.html
is an accurate representation of POSIX) doesn't require that 0, 1 and
2 be the specific values of these three constants. It merely requires
that they be defined​:

#####
The <sys/resource.h> header defines the following symbolic constants
as possible values of the which argument of getpriority() and
setpriority()​:

PRIO_PROCESS
Identifies who argument as a process ID.
PRIO_PGRP
Identifies who argument as a process group ID.
PRIO_USER
Identifies who argument as a user ID.
#####

If that's the case, then I don't think the Perl documentation should
say anything about specific values.
I agree.

Maybe the situation is similar with the SEEK_{SET,CUR,END}
constants and the values are everywhere the same,
I don't think the situation is analogous to SEEK_*. Perl explicitly
defines those three constants if they are not already defined​:

#####
perlio.h
152​:#ifndef SEEK_SET
153​:#define SEEK_SET 0
156​:#ifndef SEEK_CUR
157​:#define SEEK_CUR 1
160​:#ifndef SEEK_END
161​:#define SEEK_END 2
#####

AFAICT, Perl makes no attempt to provide values for those constants if
they are not already defined.
Fcntl provides default values for the SEEK_* constants - see ext/Fcntl/Makefile.PL

and may be
documented in perlfunc.pod? And maybe the documentation could
point to BSD​::Resource which also implements getpriority &
setpriority, but also defines the PRIO_* constants.
I don't object to mentioning CPAN modules in Perl 5 documentation,
but, other things being equal, I think we should only refer to CPAN
modules if they are well known and widely used. BSD​::Resource is
Jarkko code, so I have no doubt as to its quality. But I was unaware
of it until reading this RT and have never had occasion to use it.
I'd heard of it, but never used it. I've never used (get|set)priority() in core.

I can see three solutions​:

1) add the constants to Fcntl - except these constants aren't defined by fcntl.h, so they don't really belong.

2) create a new core module Sys​::Resource (to match <sys/resource.h>, which defines the constants. Of course this duplicates the work BSD​::Resource already does better.

3) link to BSD​::Resource

Out of these 3) seems the most palatable.

Agreed.

@p5pRT
Copy link
Author

p5pRT commented Sep 10, 2017

From @Leont

On Mon, Aug 28, 2017 at 9​:53 PM, slaven@​rezic.de <perlbug-followup@​perl.org>
wrote​:

"perldoc -f getpriority" just refers to the getpriority manpage
for the details. This is not ideal, and the manpage only mentions
the PRIO_{PROCESS,PGRP,USER} macros as possible values for the
WHICH parameter. So to find the actual values one has to look
around in include files, or write a small C program printing out
these values.

On Linux and FreeBSD systems the values are​:
#define PRIO_PROCESS 0
#define PRIO_PGRP 1
#define PRIO_USER 2
Maybe the situation is similar with the SEEK_{SET,CUR,END}
constants and the values are everywhere the same, and may be
documented in perlfunc.pod? And maybe the documentation could
point to BSD​::Resource which also implements getpriority &
setpriority, but also defines the PRIO_* constants.

Historically, people would have used h2ph to generate the constants and
then would have required the resulting sys/resource.ph; a module for these
constants wasn't needed. This approach should still work but it has never
really been ported to CPAN (yes, it's that historical). Nowadays most
builtins are covered by some module for their constants, apparently this
one slipped through the cracks.

Leon

@p5pRT
Copy link
Author

p5pRT commented Sep 11, 2017

From @tonycoz

On Sun, Sep 03, 2017 at 09​:00​:10PM -0700, Tony Cook via RT wrote​:

On Sat, 02 Sep 2017 16​:11​:22 -0700, jkeenan wrote​:

POSIX (assuming
http​://pubs.opengroup.org/onlinepubs/007908799/xsh/sysresource.h.html
is an accurate representation of POSIX) doesn't require that 0, 1 and
2 be the specific values of these three constants. It merely requires
that they be defined​:

#####
The <sys/resource.h> header defines the following symbolic constants
as possible values of the which argument of getpriority() and
setpriority()​:

PRIO_PROCESS
Identifies who argument as a process ID.
PRIO_PGRP
Identifies who argument as a process group ID.
PRIO_USER
Identifies who argument as a user ID.
#####

If that's the case, then I don't think the Perl documentation should
say anything about specific values.

I agree.

I'd heard of it, but never used it. I've never used (get|set)priority() in core.

I can see three solutions​:

1) add the constants to Fcntl - except these constants aren't defined by fcntl.h, so they don't really belong.

2) create a new core module Sys​::Resource (to match <sys/resource.h>, which defines the constants. Of course this duplicates the work BSD​::Resource already does better.

3) link to BSD​::Resource

Out of these 3) seems the most palatable.

Another option would be POSIX.pm, since these are defined in POSIX.

Tony

@p5pRT
Copy link
Author

p5pRT commented Sep 11, 2017

From @Leont

On Mon, Sep 11, 2017 at 2​:01 AM, Tony Cook <tony@​develop-help.com> wrote​:

I agree.

I'd heard of it, but never used it. I've never used (get|set)priority()
in core.

I can see three solutions​:

1) add the constants to Fcntl - except these constants aren't defined by
fcntl.h, so they don't really belong.

2) create a new core module Sys​::Resource (to match <sys/resource.h>,
which defines the constants. Of course this duplicates the work
BSD​::Resource already does better.

3) link to BSD​::Resource

Out of these 3) seems the most palatable.

Another option would be POSIX.pm, since these are defined in POSIX.

As much as I dislike how bloated POSIX already is, that does feel like the
most logical solution to me.

Leon

@p5pRT
Copy link
Author

p5pRT commented Sep 27, 2017

From @tonycoz

On Mon, 11 Sep 2017 01​:54​:53 -0700, LeonT wrote​:

On Mon, Sep 11, 2017 at 2​:01 AM, Tony Cook <tony@​develop-help.com> wrote​:

I agree.

I'd heard of it, but never used it. I've never used (get|set)priority()
in core.

I can see three solutions​:

1) add the constants to Fcntl - except these constants aren't defined by
fcntl.h, so they don't really belong.

2) create a new core module Sys​::Resource (to match <sys/resource.h>,
which defines the constants. Of course this duplicates the work
BSD​::Resource already does better.

3) link to BSD​::Resource

Out of these 3) seems the most palatable.

Another option would be POSIX.pm, since these are defined in POSIX.

As much as I dislike how bloated POSIX already is, that does feel like the
most logical solution to me.

Patching attached.

I'll apply in a few days if no-one objects.

Tony

@p5pRT
Copy link
Author

p5pRT commented Sep 27, 2017

From @tonycoz

0001-perl-131982-provide-constants-for-get-setpriority-in.patch
From b5ce3e396d2e8ed51429367eb40a755b163656bc Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 27 Sep 2017 15:18:17 +1000
Subject: (perl #131982) provide constants for get/setpriority in POSIX.pm

---
 ext/POSIX/Makefile.PL   |  3 ++-
 ext/POSIX/POSIX.xs      |  4 ++++
 ext/POSIX/lib/POSIX.pm  |  4 +++-
 ext/POSIX/lib/POSIX.pod | 12 ++++++++++++
 ext/POSIX/t/export.t    |  4 ++++
 5 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/ext/POSIX/Makefile.PL b/ext/POSIX/Makefile.PL
index bdaa4b6..6e40f59 100644
--- a/ext/POSIX/Makefile.PL
+++ b/ext/POSIX/Makefile.PL
@@ -66,7 +66,8 @@ my @names =
       _SC_ARG_MAX _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL _SC_NGROUPS_MAX
       _SC_OPEN_MAX _SC_PAGESIZE _SC_SAVED_IDS _SC_STREAM_MAX _SC_TZNAME_MAX
       _SC_VERSION EAI_AGAIN EAI_BADFLAGS EAI_FAIL EAI_FAMILY EAI_MEMORY EAI_NONAME
-      EAI_SERVICE EAI_SOCKTYPE EAI_SYSTEM EAI_OVERFLOW),
+      EAI_SERVICE EAI_SOCKTYPE EAI_SYSTEM EAI_OVERFLOW
+      PRIO_PROCESS PRIO_PGRP PRIO_USER),
    {name=>"CLK_TCK", not_constant=>1},
    {name=>"MB_CUR_MAX", not_constant=>1},
    {name=>"EXIT_FAILURE", default=>["IV", "1"]},
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 68b8881..343a9ca 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -62,6 +62,10 @@ static int not_here(const char *s);
 #include <unistd.h>
 #endif
 
+#ifdef I_SYS_RESOURCE
+# include <sys/resource.h>
+#endif
+
 #if defined(USE_QUADMATH) && defined(I_QUADMATH)
 
 #  undef M_E
diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm
index 8b1b657..2d7238a 100644
--- a/ext/POSIX/lib/POSIX.pm
+++ b/ext/POSIX/lib/POSIX.pm
@@ -4,7 +4,7 @@ use warnings;
 
 our ($AUTOLOAD, %SIGRT);
 
-our $VERSION = '1.77';
+our $VERSION = '1.78';
 
 require XSLoader;
 
@@ -437,6 +437,8 @@ my %other_export_tags = ( # cf. exports policy below
 
     stdlib_h_c99 => [ @{$default_export_tags{stdlib_h}}, 'strtold' ],
 
+    sys_resource_h => [qw(PRIO_PROCESS PRIO_PGRP PRIO_USER)],
+
     sys_socket_h => [qw(
         MSG_CTRUNC MSG_DONTROUTE MSG_EOR MSG_OOB MSG_PEEK MSG_TRUNC MSG_WAITALL
     )],
diff --git a/ext/POSIX/lib/POSIX.pod b/ext/POSIX/lib/POSIX.pod
index 9d2c032..d101ef9 100644
--- a/ext/POSIX/lib/POSIX.pod
+++ b/ext/POSIX/lib/POSIX.pod
@@ -2441,6 +2441,18 @@ C<_POSIX_TZNAME_MAX> C<_POSIX_VDISABLE> C<_POSIX_VERSION>
 
 =back
 
+=head1 RESOURCE CONSTANTS
+
+Imported with the C<:sys_resource_h> tag.
+
+=over 8
+
+=item Constants
+
+C<PRIO_PROCESS> C<PRIO_PGRP> C<PRIO_USER>
+
+=back
+
 =head1 SYSTEM CONFIGURATION
 
 =over 8
diff --git a/ext/POSIX/t/export.t b/ext/POSIX/t/export.t
index 5e07a13..6637fa6 100644
--- a/ext/POSIX/t/export.t
+++ b/ext/POSIX/t/export.t
@@ -178,6 +178,10 @@ my %expect = (
             POLL_IN POLL_OUT POLL_MSG POLL_ERR POLL_PRI POLL_HUP
             SI_USER SI_QUEUE SI_TIMER SI_ASYNCIO SI_MESGQ
         ),
+        # added in 5.27
+        qw(
+            PRIO_PROCESS PRIO_PGRP PRIO_USER
+        ),
     ],
 );
 
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Sep 27, 2017

From @tonycoz

On Tue, 26 Sep 2017 22​:20​:38 -0700, tonyc wrote​:

On Mon, 11 Sep 2017 01​:54​:53 -0700, LeonT wrote​:

On Mon, Sep 11, 2017 at 2​:01 AM, Tony Cook <tony@​develop-help.com>
wrote​:

I agree.

I'd heard of it, but never used it. I've never used
(get|set)priority()
in core.

I can see three solutions​:

1) add the constants to Fcntl - except these constants aren't
defined by
fcntl.h, so they don't really belong.

2) create a new core module Sys​::Resource (to match
<sys/resource.h>,
which defines the constants. Of course this duplicates the work
BSD​::Resource already does better.

3) link to BSD​::Resource

Out of these 3) seems the most palatable.

Another option would be POSIX.pm, since these are defined in POSIX.

As much as I dislike how bloated POSIX already is, that does feel
like the
most logical solution to me.

Patching attached.

I'll apply in a few days if no-one objects.

And this patch too.

Tony

@p5pRT
Copy link
Author

p5pRT commented Sep 27, 2017

From @tonycoz

0002-perl-131982-update-the-set-getpriority-documentation.patch
From 99d724c5c14b57ad6a78b158bd16eb05ce48934f Mon Sep 17 00:00:00 2001
From: Tony Cook <tony@develop-help.com>
Date: Wed, 27 Sep 2017 15:27:14 +1000
Subject: (perl #131982) update the set/getpriority documentation too

---
 pod/perlfunc.pod | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 665e074..e753d5f 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -2989,6 +2989,9 @@ Returns the current priority for a process, a process group, or a user.
 (See L<getpriority(2)>.)  Will raise a fatal exception if used on a
 machine that doesn't implement L<getpriority(2)>.
 
+C<WHICH> can be any of C<PRIO_PROCESS>, C<PRIO_PGRP> or C<PRIO_USER>
+imported from L<POSIX/RESOURCE CONSTANTS>.
+
 Portability issues: L<perlport/getpriority>.
 
 =item getpwnam NAME
@@ -7036,6 +7039,9 @@ Sets the current priority for a process, a process group, or a user.
 (See L<setpriority(2)>.)  Raises an exception when used on a machine
 that doesn't implement L<setpriority(2)>.
 
+C<WHICH> can be any of C<PRIO_PROCESS>, C<PRIO_PGRP> or C<PRIO_USER>
+imported from L<POSIX/RESOURCE CONSTANTS>.
+
 Portability issues: L<perlport/setpriority>.
 
 =item setsockopt SOCKET,LEVEL,OPTNAME,OPTVAL
-- 
2.1.4

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2017

From @tonycoz

On Tue, 26 Sep 2017 22​:27​:59 -0700, tonyc wrote​:

On Tue, 26 Sep 2017 22​:20​:38 -0700, tonyc wrote​:

On Mon, 11 Sep 2017 01​:54​:53 -0700, LeonT wrote​:

On Mon, Sep 11, 2017 at 2​:01 AM, Tony Cook <tony@​develop-help.com>
wrote​:

I agree.

I'd heard of it, but never used it. I've never used
(get|set)priority()
in core.

I can see three solutions​:

1) add the constants to Fcntl - except these constants aren't
defined by
fcntl.h, so they don't really belong.

2) create a new core module Sys​::Resource (to match
<sys/resource.h>,
which defines the constants. Of course this duplicates the work
BSD​::Resource already does better.

3) link to BSD​::Resource

Out of these 3) seems the most palatable.

Another option would be POSIX.pm, since these are defined in POSIX.

As much as I dislike how bloated POSIX already is, that does feel
like the
most logical solution to me.

Patching attached.

I'll apply in a few days if no-one objects.

And this patch too.

Applied to blead as 4fd667a (with an added #include) and 7596fda.

Tony

@p5pRT
Copy link
Author

p5pRT commented Oct 16, 2017

@tonycoz - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release yesterday of Perl 5.28.0, this and 185 other issues have been
resolved.

Perl 5.28.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.28.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented Jun 23, 2018

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant