[Win32utils-devel] Simulating Process.getrlimit

Heesob Park phasis at gmail.com
Mon Jul 20 20:45:25 EDT 2009


Hi,

2009/7/21 Daniel Berger <djberg96 at gmail.com>:
> Hi,
>
>> I guess the value 0 means no limit.
>
> Ok, thanks.
>
>>> The other problem I noticed is that you can't call Process.getrlimit more
>>> than once per process, presumably because I don't call TerminateJobObject.
>>> But if I call that it kills the process. I don't see a way around that. I
>>> didn't see a way to remove a process from a job object first. Is there a
>>> way?
>>>
>> If you want the information of the current process only, you don't
>> need to call CreateJobObject and AssignProcessToJobObject, just call
>> QueryInformationJobObject with null job handle.
>> But SetInformationJobObject cannot be called with null job handle.
>
> I get an error on both XP and Vista if I pass a null filehandle.
>
> require 'windows/process'
> require 'windows/error'
> include Windows::Process
> include Windows::Error
>
> buf = 0.chr * 48
> val = nil
>
> # Set the LimitFlag
> buf[16,4] = [JOB_OBJECT_LIMIT_PROCESS_TIME].pack('L')
>
> bool = QueryInformationJobObject(
>   nil,
>   JobObjectBasicLimitInformation,
>   buf,
>   buf.size,
>   nil
> )
>
> unless bool
>   raise Error, get_last_error
> end
>
> [val, val] # Return an array of two values to comply with spec
>
> What have I done wrong?
>
Sorry for misleading.
The null jobhandle works only if the current process is already a
member of a predefined job.
You must check it by calling IsProcessInJob function with null jobhandle.

Regards,

Park Heesob


More information about the win32utils-devel mailing list