Skip Menu |

This queue is for tickets about the IPC-Run CPAN distribution.

Report information
The Basics
Id: 42351
Status: resolved
Priority: 0/
Queue: IPC-Run

People
Owner: Nobody in particular
Requestors: james.lick [...] jameslick.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.82
Fixed in: (no value)



Subject: Child process priority not inherited due to hardcoded priority
In Windows there is limited process priority inheritance. If the parent priority level is 'below normal' or 'low' then child processes will by default inherit the priority level. In any other case the child will by default run with 'normal' priority. Documentation: http://msdn.microsoft.com/en-us/library/ms682425(VS.85).aspx "If none of the priority class flags is specified, the priority class defaults to NORMAL_PRIORITY_CLASS unless the priority class of the creating process is IDLE_PRIORITY_CLASS or BELOW_NORMAL_PRIORITY_CLASS. In this case, the child process receives the default priority class of the calling process." (IDLE is the same as what is elsewhere called 'low'.) However, in IPC::Run this is not working because the process is always created with 'normal' priority. This is controlled by lib/Run/Win32Helper.pm which in 0.82 on line 455 reads: Win32::Process::Create( $process, $cmd->[0], $cmd_line, 1, ## Inherit handles NORMAL_PRIORITY_CLASS, ".", ) or croak "$!: Win32::Process::Create()"; By specifying 'NORMAL_PRIORITY_CLASS' in Win32::Process::Create()'s $cflags option, children will always start with 'normal' priority. Instead, change that field to 0, e.g.: Win32::Process::Create( $process, $cmd->[0], $cmd_line, 1, ## Inherit handles 0, ".", ) or croak "$!: Win32::Process::Create()"; With this change, IPC::Run will behave the same in the common case and children will still run at 'normal' priority in most cases. However if the parent priority has been changed to 'below normal' or 'low' then the child will inherit this automatically. I believe this behavior is more correct than hardcoding the priority. It is certainly what I was expecting to happen. Even better would be to expose an option to be able to set the child process priority, but that is a much more complicated change.
Ticket migrated to github as https://github.com/toddr/IPC-Run/issues/40