Module: Process

Constant Summary

Constants included from Puppet::FFI::Windows::Functions

Puppet::FFI::Windows::Functions::SC_ENUM_TYPE, Puppet::FFI::Windows::Functions::SC_STATUS_TYPE

Constants included from Puppet::FFI::Windows::Constants

Puppet::FFI::Windows::Constants::ABOVE_NORMAL_PRIORITY_CLASS, Puppet::FFI::Windows::Constants::ALL_SERVICE_TYPES, Puppet::FFI::Windows::Constants::BELOW_NORMAL_PRIORITY_CLASS, Puppet::FFI::Windows::Constants::CREATE_BREAKAWAY_FROM_JOB, Puppet::FFI::Windows::Constants::CREATE_DEFAULT_ERROR_MODE, Puppet::FFI::Windows::Constants::CREATE_NEW_CONSOLE, Puppet::FFI::Windows::Constants::CREATE_NEW_PROCESS_GROUP, Puppet::FFI::Windows::Constants::CREATE_NO_WINDOW, Puppet::FFI::Windows::Constants::CREATE_PRESERVE_CODE_AUTHZ_LEVEL, Puppet::FFI::Windows::Constants::CREATE_PROTECTED_PROCESS, Puppet::FFI::Windows::Constants::CREATE_SEPARATE_WOW_VDM, Puppet::FFI::Windows::Constants::CREATE_SHARED_WOW_VDM, Puppet::FFI::Windows::Constants::CREATE_SUSPENDED, Puppet::FFI::Windows::Constants::CREATE_UNICODE_ENVIRONMENT, Puppet::FFI::Windows::Constants::DEBUG_ONLY_THIS_PROCESS, Puppet::FFI::Windows::Constants::DEBUG_PROCESS, Puppet::FFI::Windows::Constants::DELETE, Puppet::FFI::Windows::Constants::DETACHED_PROCESS, Puppet::FFI::Windows::Constants::ERROR_ALREADY_EXISTS, Puppet::FFI::Windows::Constants::ERROR_FILE_NOT_FOUND, Puppet::FFI::Windows::Constants::ERROR_PATH_NOT_FOUND, Puppet::FFI::Windows::Constants::ERROR_SERVICE_DOES_NOT_EXIST, Puppet::FFI::Windows::Constants::FILE_ALL_ACCESS, Puppet::FFI::Windows::Constants::FILE_APPEND_DATA, Puppet::FFI::Windows::Constants::FILE_ATTRIBUTE_DIRECTORY, Puppet::FFI::Windows::Constants::FILE_ATTRIBUTE_READONLY, Puppet::FFI::Windows::Constants::FILE_ATTRIBUTE_REPARSE_POINT, Puppet::FFI::Windows::Constants::FILE_DELETE_CHILD, Puppet::FFI::Windows::Constants::FILE_DEVICE_FILE_SYSTEM, Puppet::FFI::Windows::Constants::FILE_EXECUTE, Puppet::FFI::Windows::Constants::FILE_FLAG_BACKUP_SEMANTICS, Puppet::FFI::Windows::Constants::FILE_FLAG_OPEN_REPARSE_POINT, Puppet::FFI::Windows::Constants::FILE_GENERIC_EXECUTE, Puppet::FFI::Windows::Constants::FILE_GENERIC_READ, Puppet::FFI::Windows::Constants::FILE_GENERIC_WRITE, Puppet::FFI::Windows::Constants::FILE_READ_ATTRIBUTES, Puppet::FFI::Windows::Constants::FILE_READ_DATA, Puppet::FFI::Windows::Constants::FILE_READ_EA, Puppet::FFI::Windows::Constants::FILE_SHARE_READ, Puppet::FFI::Windows::Constants::FILE_SHARE_WRITE, Puppet::FFI::Windows::Constants::FILE_WRITE_ATTRIBUTES, Puppet::FFI::Windows::Constants::FILE_WRITE_DATA, Puppet::FFI::Windows::Constants::FILE_WRITE_EA, Puppet::FFI::Windows::Constants::FINAL_STATES, Puppet::FFI::Windows::Constants::FSCTL_GET_REPARSE_POINT, Puppet::FFI::Windows::Constants::GENERIC_ALL, Puppet::FFI::Windows::Constants::GENERIC_EXECUTE, Puppet::FFI::Windows::Constants::GENERIC_READ, Puppet::FFI::Windows::Constants::GENERIC_WRITE, Puppet::FFI::Windows::Constants::HANDLE_FLAG_INHERIT, Puppet::FFI::Windows::Constants::HIGH_PRIORITY_CLASS, Puppet::FFI::Windows::Constants::IDLE_PRIORITY_CLASS, Puppet::FFI::Windows::Constants::INHERIT_PARENT_AFFINITY, Puppet::FFI::Windows::Constants::INVALID_FILE_ATTRIBUTES, Puppet::FFI::Windows::Constants::INVALID_HANDLE_VALUE, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_CSV, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_DEDUP, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_DFS, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_DFSR, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_HSM, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_HSM2, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_MOUNT_POINT, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_NFS, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_SIS, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_SYMLINK, Puppet::FFI::Windows::Constants::IO_REPARSE_TAG_WIM, Puppet::FFI::Windows::Constants::LOGON_WITH_PROFILE, Puppet::FFI::Windows::Constants::MAXIMUM_REPARSE_DATA_BUFFER_SIZE, Puppet::FFI::Windows::Constants::METHOD_BUFFERED, Puppet::FFI::Windows::Constants::NORMAL_PRIORITY_CLASS, Puppet::FFI::Windows::Constants::OPEN_EXISTING, Puppet::FFI::Windows::Constants::PROCESS_ALL_ACCESS, Puppet::FFI::Windows::Constants::PROCESS_QUERY_INFORMATION, Puppet::FFI::Windows::Constants::PROCESS_SET_INFORMATION, Puppet::FFI::Windows::Constants::PROCESS_TERMINATE, Puppet::FFI::Windows::Constants::PROCESS_VM_READ, Puppet::FFI::Windows::Constants::REALTIME_PRIORITY_CLASS, Puppet::FFI::Windows::Constants::REPLACEFILE_IGNORE_ACL_ERRORS, Puppet::FFI::Windows::Constants::REPLACEFILE_IGNORE_MERGE_ERRORS, Puppet::FFI::Windows::Constants::REPLACEFILE_WRITE_THROUGH, Puppet::FFI::Windows::Constants::SC_MANAGER_ALL_ACCESS, Puppet::FFI::Windows::Constants::SC_MANAGER_CONNECT, Puppet::FFI::Windows::Constants::SC_MANAGER_CREATE_SERVICE, Puppet::FFI::Windows::Constants::SC_MANAGER_ENUMERATE_SERVICE, Puppet::FFI::Windows::Constants::SC_MANAGER_LOCK, Puppet::FFI::Windows::Constants::SC_MANAGER_MODIFY_BOOT_CONFIG, Puppet::FFI::Windows::Constants::SC_MANAGER_QUERY_LOCK_STATUS, Puppet::FFI::Windows::Constants::SEM_FAILCRITICALERRORS, Puppet::FFI::Windows::Constants::SEM_NOGPFAULTERRORBOX, Puppet::FFI::Windows::Constants::SERVICENAME_MAX, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_HARDWAREPROFILECHANGE, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_NETBINDCHANGE, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_PARAMCHANGE, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_PAUSE_CONTINUE, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_POWEREVENT, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_PRESHUTDOWN, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_SESSIONCHANGE, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_SHUTDOWN, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_STOP, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_TIMECHANGE, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_TRIGGEREVENT, Puppet::FFI::Windows::Constants::SERVICE_ACCEPT_USER_LOGOFF, Puppet::FFI::Windows::Constants::SERVICE_ACTIVE, Puppet::FFI::Windows::Constants::SERVICE_ALL_ACCESS, Puppet::FFI::Windows::Constants::SERVICE_AUTO_START, Puppet::FFI::Windows::Constants::SERVICE_BOOT_START, Puppet::FFI::Windows::Constants::SERVICE_CHANGE_CONFIG, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_DELAYED_AUTO_START_INFO, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_DESCRIPTION, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_FAILURE_ACTIONS, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_FAILURE_ACTIONS_FLAG, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_LAUNCH_PROTECTED, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_PREFERRED_NODE, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_PRESHUTDOWN_INFO, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_SERVICE_SID_INFO, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_TRIGGER_INFO, Puppet::FFI::Windows::Constants::SERVICE_CONFIG_TYPES, Puppet::FFI::Windows::Constants::SERVICE_CONTINUE_PENDING, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_CONTINUE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_DEVICEEVENT, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_HARDWAREPROFILECHANGE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_INTERROGATE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_NETBINDADD, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_NETBINDDISABLE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_NETBINDENABLE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_NETBINDREMOVE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_PARAMCHANGE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_PAUSE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_POWEREVENT, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_PRESHUTDOWN, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_SESSIONCHANGE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_SHUTDOWN, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_SIGNALS, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_STOP, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_TIMECHANGE, Puppet::FFI::Windows::Constants::SERVICE_CONTROL_TRIGGEREVENT, Puppet::FFI::Windows::Constants::SERVICE_DEMAND_START, Puppet::FFI::Windows::Constants::SERVICE_DISABLED, Puppet::FFI::Windows::Constants::SERVICE_ENUMERATE_DEPENDENTS, Puppet::FFI::Windows::Constants::SERVICE_FILE_SYSTEM_DRIVER, Puppet::FFI::Windows::Constants::SERVICE_INACTIVE, Puppet::FFI::Windows::Constants::SERVICE_INTERACTIVE_PROCESS, Puppet::FFI::Windows::Constants::SERVICE_INTERROGATE, Puppet::FFI::Windows::Constants::SERVICE_KERNEL_DRIVER, Puppet::FFI::Windows::Constants::SERVICE_NO_CHANGE, Puppet::FFI::Windows::Constants::SERVICE_PAUSED, Puppet::FFI::Windows::Constants::SERVICE_PAUSE_CONTINUE, Puppet::FFI::Windows::Constants::SERVICE_PAUSE_PENDING, Puppet::FFI::Windows::Constants::SERVICE_QUERY_CONFIG, Puppet::FFI::Windows::Constants::SERVICE_QUERY_STATUS, Puppet::FFI::Windows::Constants::SERVICE_RUNNING, Puppet::FFI::Windows::Constants::SERVICE_START, Puppet::FFI::Windows::Constants::SERVICE_START_PENDING, Puppet::FFI::Windows::Constants::SERVICE_START_TYPES, Puppet::FFI::Windows::Constants::SERVICE_STATES, Puppet::FFI::Windows::Constants::SERVICE_STATE_ALL, Puppet::FFI::Windows::Constants::SERVICE_STOP, Puppet::FFI::Windows::Constants::SERVICE_STOPPED, Puppet::FFI::Windows::Constants::SERVICE_STOP_PENDING, Puppet::FFI::Windows::Constants::SERVICE_SYSTEM_START, Puppet::FFI::Windows::Constants::SERVICE_USER_DEFINED_CONTROL, Puppet::FFI::Windows::Constants::SERVICE_USER_OWN_PROCESS, Puppet::FFI::Windows::Constants::SERVICE_USER_SHARE_PROCESS, Puppet::FFI::Windows::Constants::SERVICE_WIN32_OWN_PROCESS, Puppet::FFI::Windows::Constants::SERVICE_WIN32_SHARE_PROCESS, Puppet::FFI::Windows::Constants::SHGFI_DISPLAYNAME, Puppet::FFI::Windows::Constants::SHGFI_PIDL, Puppet::FFI::Windows::Constants::SPECIFIC_RIGHTS_ALL, Puppet::FFI::Windows::Constants::STANDARD_RIGHTS_ALL, Puppet::FFI::Windows::Constants::STANDARD_RIGHTS_EXECUTE, Puppet::FFI::Windows::Constants::STANDARD_RIGHTS_READ, Puppet::FFI::Windows::Constants::STANDARD_RIGHTS_REQUIRED, Puppet::FFI::Windows::Constants::STANDARD_RIGHTS_WRITE, Puppet::FFI::Windows::Constants::STARTF_USESTDHANDLES, Puppet::FFI::Windows::Constants::SYNCHRONIZE, Puppet::FFI::Windows::Constants::TOKEN_INFORMATION_CLASS, Puppet::FFI::Windows::Constants::UNSAFE_PENDING_STATES, Puppet::FFI::Windows::Constants::WRITE_DAC, Puppet::FFI::Windows::Constants::WRITE_OWNER

Constants included from Puppet::FFI::Windows::Structs

Puppet::FFI::Windows::Structs::MAXIMUM_REPARSE_DATA_BUFFER_SIZE

Class Method Summary collapse

Methods included from FFI::Library

attach_function_private

Methods included from Puppet::Util::Windows::String

wide_string

Class Method Details

.create(args) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/puppet/util/windows/monkey_patches/process.rb', line 120

def create(args)
  # Validate that args is a Hash
  validate_args(args)

  initialize_defaults

  # Validate the keys, and convert symbols and case to lowercase strings.
  validate_keys(args)

  # If the startup_info key is present, validate its subkeys
  validate_startup_info if hash[:startup_info]

  # validates that 'app_name' or 'command_line' is set
  validate_command_line

  if hash[:app_name] && !hash[:command_line]
    hash[:command_line] = hash[:app_name]
    hash[:app_name] = nil
  end

  # Setup stdin, stdout and stderr handlers
  setup_std_handlers

  if logon
    create_process_with_logon
  else
    create_process
  end

  # Automatically close the process and thread handles in the
  # PROCESS_INFORMATION struct unless explicitly told not to.
  if hash[:close_handles]
    FFI::WIN32.CloseHandle(procinfo[:hProcess])
    FFI::WIN32.CloseHandle(procinfo[:hThread])
  end

  ProcessInfo.new(
    procinfo[:hProcess],
    procinfo[:hThread],
    procinfo[:dwProcessId],
    procinfo[:dwThreadId]
  )
end

.setpriority(kind, int, int_priority) ⇒ Object

Sets the priority class for the specified process id int.

The kind parameter is ignored but present for API compatibility. You can only retrieve process information, not process group or user information, so it is effectively always Process::PRIO_PROCESS.

Possible int_priority values are:

  • Process::NORMAL_PRIORITY_CLASS

  • Process::IDLE_PRIORITY_CLASS

  • Process::HIGH_PRIORITY_CLASS

  • Process::REALTIME_PRIORITY_CLASS

  • Process::BELOW_NORMAL_PRIORITY_CLASS

  • Process::ABOVE_NORMAL_PRIORITY_CLASS

Raises:

  • (TypeError)


181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/puppet/util/windows/monkey_patches/process.rb', line 181

def setpriority(kind, int, int_priority)
  raise TypeError unless kind.is_a?(Integer)
  raise TypeError unless int.is_a?(Integer)
  raise TypeError unless int_priority.is_a?(Integer)

  int = Process.pid if int == 0
  handle = OpenProcess(PROCESS_SET_INFORMATION, 0, int)

  if handle == 0
    raise SystemCallError, FFI.errno, "OpenProcess"
  end

  begin
    result = SetPriorityClass(handle, int_priority)
    raise SystemCallError, FFI.errno, "SetPriorityClass" unless result
  ensure
    FFI::WIN32.CloseHandle(handle)
  end

  return 0
end