class CZMQ::FFI::Zproc
process configuration and status @note This class is 100% generated using zproject.
Public Class Methods
@param ptr [::FFI::Pointer] @return [Proc]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 35 def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zproc_destroy ptr_ptr end end
Attaches the pointer ptr to this instance and defines a finalizer for it if necessary. @param ptr [::FFI::Pointer] @param finalize [Boolean]
# 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
Create a new zproc. NOTE: On Windows and with libzmq3 and libzmq2 this function returns NULL. Code needs to be ported there. @return [CZMQ::Zproc]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 80 def self.new() ptr = ::CZMQ::FFI.zproc_new() __new ptr end
Self test of this class.
@param verbose [Boolean] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 321 def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zproc_test(verbose) result end
Public Instance Methods
Return internal pointer @return [::FFI::Pointer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 48 def __ptr raise DestroyedError unless @ptr @ptr end
Nullify internal pointer and return pointer pointer. @note This detaches the current instance from the native object
and thus makes it unusable.
@return [::FFI::MemoryPointer] the pointer pointing to a pointer
pointing to the native object
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 59 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
Undefines the finalizer for this object. @note Only use this if you need to and can guarantee that the native
object will be freed by other means.
@return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 71 def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end
return internal actor, useful for the polling if process died
@return [::FFI::Pointer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 286 def actor() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_actor(self_p) result end
Return command line arguments (the first item is the executable) or NULL if not set.
@return [Zlist]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 99 def args() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_args(self_p) result = Zlist.__new result, true result end
Destroy zproc, wait until process ends.
@return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 88 def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zproc_destroy(self_p) result end
send a signal to the subprocess
@param signal [Integer, to_int, to_i] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 297 def kill(signal) raise DestroyedError unless @ptr self_p = @ptr signal = Integer(signal) result = ::CZMQ::FFI.zproc_kill(self_p, signal) result end
@return [Boolean]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 43 def null? !@ptr or @ptr.null? end
PID of the process
@return [Integer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 240 def pid() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_pid(self_p) result end
process exit code
@return [Integer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 230 def returncode() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_returncode(self_p) result end
Starts the process, return just before execve/CreateProcess.
@return [Integer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 220 def run() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_run(self_p) result end
return true if process is running, false if not yet started or finished
@return [Boolean]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 250 def running() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_running(self_p) result end
Setup the command line arguments, the first item must be an (absolute) filename to run.
@param arguments [#__ptr_give_ref] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 112 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
Setup the command line arguments, the first item must be an (absolute) filename to run. Variadic function, must be NULL terminated.
@param arguments [String, to_s, nil] @param args [Array<Object>] see github.com/ffi/ffi/wiki/examples#using-varargs @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 126 def set_argsx(arguments, *args) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_set_argsx(self_p, arguments, *args) result end
Setup the environment variables for the process.
@param arguments [#__ptr_give_ref] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 137 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
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.
@param socket [::FFI::Pointer, to_ptr
] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 177 def set_stderr(socket) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_set_stderr(self_p, socket) result end
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.
@param socket [::FFI::Pointer, to_ptr
] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 151 def set_stdin(socket) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_set_stdin(self_p, socket) result end
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.
@param socket [::FFI::Pointer, to_ptr
] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 164 def set_stdout(socket) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_set_stdout(self_p, socket) result end
set verbose mode
@param verbose [Boolean] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 309 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
send SIGTERM signal to the subprocess, wait for grace period and eventually send SIGKILL
@param timeout [Integer, to_int, to_i] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 275 def shutdown(timeout) raise DestroyedError unless @ptr self_p = @ptr timeout = Integer(timeout) result = ::CZMQ::FFI.zproc_shutdown(self_p, timeout) result end
Return subprocess stderr readable socket. NULL for not initialized or external sockets.
@return [::FFI::Pointer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 210 def stderr() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_stderr(self_p) result end
Return subprocess stdin writable socket. NULL for not initialized or external sockets.
@return [::FFI::Pointer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 188 def stdin() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_stdin(self_p) result end
Return subprocess stdout readable socket. NULL for not initialized or external sockets.
@return [::FFI::Pointer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 199 def stdout() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zproc_stdout(self_p) result end
So external Libraries can just pass the Object to a FFI
function which expects a :pointer
The timeout should be zero or greater, or -1 to wait indefinitely. wait or poll process status, return return code
@param timeout [Integer, to_int, to_i] @return [Integer]
# File lib/czmq-ffi-gen/czmq/ffi/zproc.rb, line 262 def wait(timeout) raise DestroyedError unless @ptr self_p = @ptr timeout = Integer(timeout) result = ::CZMQ::FFI.zproc_wait(self_p, timeout) result end