Class: CZMQ::FFI::Zproc

Inherits:
Object
  • Object
show all
Defined in:
lib/czmq-ffi-gen/czmq/ffi/zproc.rb

Overview

Note:

This class is 100% generated using zproject.

process configuration and status

Defined Under Namespace

Classes: DestroyedError

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr, finalize = true) ⇒ Zproc

Attaches the pointer ptr to this instance and defines a finalizer for it if necessary.

Parameters:

  • ptr (::FFI::Pointer)
  • finalize (Boolean) (defaults to: true)


24
25
26
27
28
29
30
31
32
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 24

def initialize(ptr, finalize = true)
  @ptr = ptr
  if @ptr.null?
    @ptr = nil # Remove null pointers so we don't have to test for them.
  elsif finalize
    @finalizer = self.class.create_finalizer_for @ptr
    ObjectSpace.define_finalizer self, @finalizer
  end
end

Class Method Details

.__newObject



18
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 18

alias :__new :new

.create_finalizer_for(ptr) ⇒ Proc

Parameters:

  • ptr (::FFI::Pointer)

Returns:

  • (Proc)


35
36
37
38
39
40
41
42
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 35

def self.create_finalizer_for(ptr)
  ptr_ptr = ::FFI::MemoryPointer.new :pointer

  Proc.new do
    ptr_ptr.write_pointer ptr
    ::CZMQ::FFI.zproc_destroy ptr_ptr
  end
end

.newCZMQ::Zproc

Create a new zproc. NOTE: On Windows and with libzmq3 and libzmq2 this function returns NULL. Code needs to be ported there.

Returns:

  • (CZMQ::Zproc)


81
82
83
84
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 81

def self.new()
  ptr = ::CZMQ::FFI.zproc_new()
  __new ptr
end

.test(verbose) ⇒ void

This method returns an undefined value.

Self test of this class.

Parameters:

  • verbose (Boolean)


322
323
324
325
326
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 322

def self.test(verbose)
  verbose = !(0==verbose||!verbose) # boolean
  result = ::CZMQ::FFI.zproc_test(verbose)
  result
end

Instance Method Details

#__ptr::FFI::Pointer Also known as: to_ptr

Return internal pointer

Returns:

  • (::FFI::Pointer)

Raises:



49
50
51
52
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 49

def __ptr
  raise DestroyedError unless @ptr
  @ptr
end

#__ptr_give_ref::FFI::MemoryPointer

Note:

This detaches the current instance from the native object and thus makes it unusable.

Nullify internal pointer and return pointer pointer.

Returns:

  • (::FFI::MemoryPointer)

    the pointer pointing to a pointer pointing to the native object

Raises:



60
61
62
63
64
65
66
67
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 60

def __ptr_give_ref
  raise DestroyedError unless @ptr
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
  ptr_ptr.write_pointer @ptr
  __undef_finalizer if @finalizer
  @ptr = nil
  ptr_ptr
end

#__undef_finalizervoid

Note:

Only use this if you need to and can guarantee that the native object will be freed by other means.

This method returns an undefined value.

Undefines the finalizer for this object.



72
73
74
75
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 72

def __undef_finalizer
  ObjectSpace.undefine_finalizer self
  @finalizer = nil
end

#actor::FFI::Pointer

return internal actor, useful for the polling if process died

Returns:

  • (::FFI::Pointer)

Raises:



287
288
289
290
291
292
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 287

def actor()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_actor(self_p)
  result
end

#argsZlist

Return command line arguments (the first item is the executable) or NULL if not set.

Returns:

Raises:



100
101
102
103
104
105
106
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 100

def args()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_args(self_p)
  result = Zlist.__new result, true
  result
end

#destroyvoid

This method returns an undefined value.

Destroy zproc, wait until process ends.



89
90
91
92
93
94
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 89

def destroy()
  return unless @ptr
  self_p = __ptr_give_ref
  result = ::CZMQ::FFI.zproc_destroy(self_p)
  result
end

#kill(signal) ⇒ void

This method returns an undefined value.

send a signal to the subprocess

Parameters:

  • signal (Integer, #to_int, #to_i)

Raises:



298
299
300
301
302
303
304
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 298

def kill(signal)
  raise DestroyedError unless @ptr
  self_p = @ptr
  signal = Integer(signal)
  result = ::CZMQ::FFI.zproc_kill(self_p, signal)
  result
end

#null?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 44

def null?
  !@ptr or @ptr.null?
end

#pidInteger

PID of the process

Returns:

  • (Integer)

Raises:



241
242
243
244
245
246
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 241

def pid()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_pid(self_p)
  result
end

#returncodeInteger

process exit code

Returns:

  • (Integer)

Raises:



231
232
233
234
235
236
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 231

def returncode()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_returncode(self_p)
  result
end

#runInteger

Starts the process, return just before execve/CreateProcess.

Returns:

  • (Integer)

Raises:



221
222
223
224
225
226
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 221

def run()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_run(self_p)
  result
end

#runningBoolean

return true if process is running, false if not yet started or finished

Returns:

  • (Boolean)

Raises:



251
252
253
254
255
256
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 251

def running()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_running(self_p)
  result
end

#set_args(arguments) ⇒ void

This method returns an undefined value.

Setup the command line arguments, the first item must be an (absolute) filename to run.

Parameters:

Raises:



113
114
115
116
117
118
119
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 113

def set_args(arguments)
  raise DestroyedError unless @ptr
  self_p = @ptr
  arguments = arguments.__ptr_give_ref
  result = ::CZMQ::FFI.zproc_set_args(self_p, arguments)
  result
end

#set_argsx(arguments, *args) ⇒ void

This method returns an undefined value.

Setup the command line arguments, the first item must be an (absolute) filename to run. Variadic function, must be NULL terminated.

Parameters:

Raises:



127
128
129
130
131
132
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 127

def set_argsx(arguments, *args)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_set_argsx(self_p, arguments, *args)
  result
end

#set_env(arguments) ⇒ void

This method returns an undefined value.

Setup the environment variables for the process.

Parameters:

Raises:



138
139
140
141
142
143
144
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 138

def set_env(arguments)
  raise DestroyedError unless @ptr
  self_p = @ptr
  arguments = arguments.__ptr_give_ref
  result = ::CZMQ::FFI.zproc_set_env(self_p, arguments)
  result
end

#set_stderr(socket) ⇒ void

This method returns an undefined value.

Connects process stderr with a writable (‘@’, bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stderr method.

Parameters:

  • socket (::FFI::Pointer, #to_ptr)

Raises:



178
179
180
181
182
183
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 178

def set_stderr(socket)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_set_stderr(self_p, socket)
  result
end

#set_stdin(socket) ⇒ void

This method returns an undefined value.

Connects process stdin with a readable (‘>’, connect) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The writable one is then accessbile via zproc_stdin method.

Parameters:

  • socket (::FFI::Pointer, #to_ptr)

Raises:



152
153
154
155
156
157
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 152

def set_stdin(socket)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_set_stdin(self_p, socket)
  result
end

#set_stdout(socket) ⇒ void

This method returns an undefined value.

Connects process stdout with a writable (‘@’, bind) zeromq socket. If socket argument is NULL, zproc creates own managed pair of inproc sockets. The readable one is then accessbile via zproc_stdout method.

Parameters:

  • socket (::FFI::Pointer, #to_ptr)

Raises:



165
166
167
168
169
170
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 165

def set_stdout(socket)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_set_stdout(self_p, socket)
  result
end

#set_verbose(verbose) ⇒ void

This method returns an undefined value.

set verbose mode

Parameters:

  • verbose (Boolean)

Raises:



310
311
312
313
314
315
316
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 310

def set_verbose(verbose)
  raise DestroyedError unless @ptr
  self_p = @ptr
  verbose = !(0==verbose||!verbose) # boolean
  result = ::CZMQ::FFI.zproc_set_verbose(self_p, verbose)
  result
end

#shutdown(timeout) ⇒ void

This method returns an undefined value.

send SIGTERM signal to the subprocess, wait for grace period and eventually send SIGKILL

Parameters:

  • timeout (Integer, #to_int, #to_i)

Raises:



276
277
278
279
280
281
282
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 276

def shutdown(timeout)
  raise DestroyedError unless @ptr
  self_p = @ptr
  timeout = Integer(timeout)
  result = ::CZMQ::FFI.zproc_shutdown(self_p, timeout)
  result
end

#stderr::FFI::Pointer

Return subprocess stderr readable socket. NULL for not initialized or external sockets.

Returns:

  • (::FFI::Pointer)

Raises:



211
212
213
214
215
216
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 211

def stderr()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_stderr(self_p)
  result
end

#stdin::FFI::Pointer

Return subprocess stdin writable socket. NULL for not initialized or external sockets.

Returns:

  • (::FFI::Pointer)

Raises:



189
190
191
192
193
194
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 189

def stdin()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_stdin(self_p)
  result
end

#stdout::FFI::Pointer

Return subprocess stdout readable socket. NULL for not initialized or external sockets.

Returns:

  • (::FFI::Pointer)

Raises:



200
201
202
203
204
205
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 200

def stdout()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zproc_stdout(self_p)
  result
end

#wait(timeout) ⇒ Integer

The timeout should be zero or greater, or -1 to wait indefinitely. wait or poll process status, return return code

Parameters:

  • timeout (Integer, #to_int, #to_i)

Returns:

  • (Integer)

Raises:



263
264
265
266
267
268
269
# File 'lib/czmq-ffi-gen/czmq/ffi/zproc.rb', line 263

def wait(timeout)
  raise DestroyedError unless @ptr
  self_p = @ptr
  timeout = Integer(timeout)
  result = ::CZMQ::FFI.zproc_wait(self_p, timeout)
  result
end