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
Comments
From @eserteThis is a bug report for perl from slaven@rezic.de, "perldoc -f getpriority" just refers to the getpriority manpage On Linux and FreeBSD systems the values are: Flags: This perlbug was built using Perl 5.20.2 - Sat Jun 3 12:27:58 UTC 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: @INC for perl 5.24.1: Environment for perl 5.24.1: |
From @jkeenanOn Mon, 28 Aug 2017 19:53:52 GMT, slaven@rezic.de wrote:
Underdocumented ... and apparently undertested as well -- as inspection of results from the following will show: #####
-- |
The RT System itself - Status changed from 'new' to 'open' |
From @jkeenanOn Mon, 28 Aug 2017 19:53:52 GMT, slaven@rezic.de 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: ##### PRIO_PROCESS If that's the case, then I don't think the Perl documentation should say anything about specific values.
I don't think the situation is analogous to SEEK_*. Perl explicitly defines those three constants if they are not already defined: ##### AFAICT, Perl makes no attempt to provide values for those constants if they are not already defined.
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. |
From @tonycozOn Sat, 02 Sep 2017 16:11:22 -0700, jkeenan wrote:
I agree.
Fcntl provides default values for the SEEK_* constants - see ext/Fcntl/Makefile.PL
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 |
From @xsawyerxOn 09/04/2017 07:00 AM, Tony Cook via RT wrote:
Agreed. |
From @LeontOn Mon, Aug 28, 2017 at 9:53 PM, slaven@rezic.de <perlbug-followup@perl.org>
Historically, people would have used h2ph to generate the constants and Leon |
From @tonycozOn Sun, Sep 03, 2017 at 09:00:10PM -0700, Tony Cook via RT wrote:
Another option would be POSIX.pm, since these are defined in POSIX. Tony |
From @LeontOn Mon, Sep 11, 2017 at 2:01 AM, Tony Cook <tony@develop-help.com> wrote:
As much as I dislike how bloated POSIX already is, that does feel like the Leon |
From @tonycozOn Mon, 11 Sep 2017 01:54:53 -0700, LeonT wrote:
Patching attached. I'll apply in a few days if no-one objects. Tony |
From @tonycoz0001-perl-131982-provide-constants-for-get-setpriority-in.patchFrom 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
|
From @tonycozOn Tue, 26 Sep 2017 22:20:38 -0700, tonyc wrote:
And this patch too. Tony |
From @tonycoz0002-perl-131982-update-the-set-getpriority-documentation.patchFrom 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
|
From @tonycozOn Tue, 26 Sep 2017 22:27:59 -0700, tonyc wrote:
Applied to blead as 4fd667a (with an added #include) and 7596fda. Tony |
@tonycoz - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank 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 Perl 5.28.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#131982 (status was 'resolved')
Searchable as RT131982$
The text was updated successfully, but these errors were encountered: