README.md in frontkick-0.5.6 vs README.md in frontkick-0.5.7
- old
+ new
@@ -68,20 +68,20 @@
```
ruby
└─ echo
```
-NOTE: This interface is different with Kernel.spawn or Open3.popen3, but similar to IO.popen. Kernel.spawn or Open3.popen3 works with no shell if multiple arguments are given:
+NOTE: This **no shell** interface is similar to IO.popen which work as:
```
-spawn('echo', '*')
+IO.popen(['echo', '*'])
```
-IO.popen works with no shell if an array argument is given:
+but different with Kernel.spawn, or Open3.popen3 which work as:
```
-IO.popen(['echo', '*'])
+spawn('echo', '*')
```
### Environment Variables
You can pass environment variables as a hash for the 1st argument as [spawn](https://ruby-doc.org/core-2.4.0/Kernel.html#method-i-spawn).
@@ -91,67 +91,74 @@
```
### Dry Run Option
```ruby
-result = Frontkick.exec(["echo", "*"], :dry_run => true)
+result = Frontkick.exec(["echo", "*"], dry_run: true)
puts result.stdout #=> echo \*
```
### Timeout Option
```ruby
-Frontkick.exec("sleep 2 && ls /hoge", :timeout => 1) # raises Frontkick::Timeout
+Frontkick.exec("sleep 2 && ls /hoge", timeout: 1) # raises Frontkick::Timeout
```
+The default signal that is sent to the command is `SIGINT`.
+You can change the signal as below.
+
+```ruby
+Frontkick.exec("sleep 2 && ls /hoge", timeout: 1, timeout_kill_signal: 'SIGTERM') # raises Frontkick::Timeout
+```
+
not to kill timeouted process
```ruby
-Frontkick.exec("sleep 2 && ls /hoge", :timeout => 1, :timeout_kill => false) # raises Frontkick::Timeout
+Frontkick.exec("sleep 2 && ls /hoge", timeout: 1, timeout_kill: false) # raises Frontkick::Timeout
```
### Exclusive Option
Prohibit another process to run a command concurrently
```ruby
-Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock") # raises Fontkick::Locked if locked
+Frontkick.exec("sleep 2 && ls /hoge", exclusive: "/tmp/frontkick.lock") # raises Fontkick::Locked if locked
```
If you prefer to be blocked:
```ruby
-Frontkick.exec("sleep 2 && ls /hoge", :exclusive => "/tmp/frontkick.lock", :exclusive_blocking => true)
+Frontkick.exec("sleep 2 && ls /hoge", exclusive: "/tmp/frontkick.lock", exclusive_blocking: true)
```
### Redirect Options (:out and :err)
```ruby
-Frontkick.exec(["ls /something_not_found"], :out => 'stdout.txt', :err => 'stderr.txt')
+Frontkick.exec(["ls /something_not_found"], out: 'stdout.txt', err: 'stderr.txt')
```
This redirects STDOUT and STDERR into files. In this case, result.stdout, and result.stderr are the given filename.
```ruby
out = File.open('stdout.txt', 'w').tap {|fp| fp.sync = true }
err = File.open('stderr.txt', 'w').tap {|fp| fp.sync = true }
-Frontkick.exec(["ls /something_not_found"], :out => out, :err => err)
+Frontkick.exec(["ls /something_not_found"], out: out, err: err)
```
You can also give IO objects. In this case, result.stdout, and result.stderr are the given IO objects.
### Popen2e Option (Get stdout and stderr together)
```ruby
-result = Frontkick.exec("echo foo; ls /something_not_found", :popen2e => true)
+result = Frontkick.exec("echo foo; ls /something_not_found", popen2e: true)
puts result.output #=>
foo
ls: /something_not_found: No such file or directory
```
-### Popen3 Options (such as :chdir)
+### Other Popen3 Options (such as :chdir)
-Other options such as :chdir are treated as options of `Open3.#popen3`.
+Other options such as :chdir are treated as options of `Open3.#popen3` (or `Open3.#popen2e` for the case of `popen2e: true`)
### Kill Child Process
Although sending a signal to a kicked child process directly causes no problem (frontkick process can take care of it),
sending a signal to a frontkick process may cause a problem that a child process becomes an orphan process.