Process module for mruby
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is 175 commits ahead, 2 commits behind iij:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
include/mruby/ext
mrblib
src
test
.appveyor.yml
.gitignore
.rubocop.yml
.travis.yml
README.md
Rakefile
build_config.rb
mrbgem.rake

README.md

mruby-process
Build Status Build status codebeat badge

Implementation of the Ruby 2.4.1 Core Library Process for mruby.

All listed methods have been tested with Ubuntu, MacOS and Windows. Cross compilation works as well.

system { VAR: 'var' }, 'echo $VAR', out: pipe

Include mruby/ext/process.h to use the native methods within your own project:

// To use kill, waitpid, fork, spawn, ... on Unix and Win32

#ifdef HAVE_MRB_PROCESS_H
# include "mruby/ext/process.h"
#endif

static pid_t
spawn_process(const char *path, char *const argv[], char *const envp[])
{
    return spawnve(path, argv, envp);
}

Installation

Add the line below to your build_config.rb:

MRuby::Build.new do |conf|
  # ... (snip) ...
  conf.gem 'mruby-process2'
  # conf.gem github: 'appPlant/mruby-process'
end

Or add this line to your aplication's mrbgem.rake:

MRuby::Gem::Specification.new('your-mrbgem') do |spec|
  # ... (snip) ...
  spec.add_dependency 'mruby-process', mgem 'mruby-process2'
end

Implemented methods

Process

method mruby-process Comment
$0 o
$PROGRAM_NAME o
$$ o
$PID o
$PROCESS_ID o
::WNOHANG o
::WUNTRACED o
#abort o
#argv0 o
#clock_getres
#clock_gettime
#daemon
#detach
#egid Implemented in mruby-process-ext
#egid= Implemented in mruby-process-sys
#euid Implemented in mruby-process-ext
#euid= Implemented in mruby-process-sys
#exec o
#exit o
#exit! o
#fork o If fork is not usable, Process.respond_to?(:fork) returns false.
#getpgid
#getpgrp
#getpriority
#getrlimit
#getsid
#gid Implemented in mruby-process-ext
#gid= Implemented in mruby-process-sys
#groups Implemented in mruby-process-sys
#groups= Implemented in mruby-process-sys
#initgroups
#kill o
#maxgroups
#maxgroups=
#pid o
#ppid o
#setpgid
#setpgrp
#setpriority
#setproctitle
#setrlimit
#setsid
#spawn o
#times
#uid Implemented in mruby-process-ext
#uid= Implemented in mruby-process-ext
#wait o
#wait2 o
#waitall o
#waitpid o
#waitpid2 o

Process::Status

method mruby-process
$? o
$CHILD_STATUS o
#&
#== o
#>> o
#coredump? o
#exited? o
#exitstatus o
#inspect o
#pid o
#signaled? o
#stopped? o
#stopsig o
#success? o
#termsig o
#to_i o
#to_s o

Kernel

method mruby-process Comment
#` Implemented in mruby-io.
#abort o
#exec o
#exit o
#exit! o
#fork o If fork is not usable, Process.respond_to?(:fork) returns false.
#sleep Implemented in mruby-sleep.
#spawn o
#system o

Signal

method mruby-process Comment
::signame o
::list o
::trap Implemented in mruby-signal.

Development

Clone the repo:

$ git clone https://github.com/appplant/mruby-process.git && cd mruby-process/

Compile the source:

$ rake compile

Run the tests:

$ rake test

Caveats

  • $? may not work correctly on the platform where pid_t is not int or MRB_INT_MAX is less than PID_MAX (or /proc/sys/kernel/pid_max).

License

Copyright (c) 2012 Internet Initiative Japan Inc. Copyright (c) 2017 appPlant GmbH.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.