[Win32utils-devel] Simulating Process.getrlimit

Daniel Berger djberg96 at gmail.com
Mon Jul 20 11:26:37 EDT 2009


> 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(

unless bool
   raise Error, get_last_error

[val, val] # Return an array of two values to comply with spec

What have I done wrong?



More information about the win32utils-devel mailing list