aw 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/aw.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b3e173f5eb48d67ae27b75d5d59330b8483119700ac8f9215eaf1f2ab2c7980
|
|
4
|
+
data.tar.gz: d8249389baeeeacffaefe74222a1686e2d311d32292df8e9b2665ba68c2d34a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48aadec08cd55c084eb66e894ec0189e8fdcab084bcf33b6cba4d42cd739af2045561f05fc14a1463be2593a648ba3fc49514bcd262ee20ef010441668ba22b4
|
|
7
|
+
data.tar.gz: 942922f6a3b48f6027f4269378bbab2ba7c81dea9a9e76555b587d00e7f952f265be27e41d3eaf9ddb14bededb21f29cbfbf6f6a9c6a903c867ece7c197e0188
|
data/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
-
Runs a block in a forked child process and brings back what it returned, or re-raises what it raised. What the block does to the process stays in the child; what it does outside, to files or to other processes,
|
|
11
|
+
Runs a block in a forked child process and brings back what it returned, or re-raises what it raised. What the block does to the process stays in the child; what it does outside, to files or to other processes, happens.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
@@ -17,7 +17,7 @@ Runs a block in a forked child process and brings back what it returned, or re-r
|
|
|
17
17
|
gem "aw"
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Aw requires Ruby 3.3 or later and `fork(2)`: it
|
|
20
|
+
Aw requires Ruby 3.3 or later and `fork(2)`: it is tested with CRuby on Linux and macOS, and declines where `fork` is missing (Windows, JRuby) with a `NotImplementedError`. `Aw.supported?` tells beforehand.
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
@@ -78,7 +78,7 @@ The value that comes back is a copy: an object returns as a new object, and its
|
|
|
78
78
|
- Aw has no timeout of its own: `fork!` and `fork?` wait until the child exits, whatever keeps it alive (a block that loops or sleeps, a child stopped by `SIGSTOP`, a standard stream whose `flush` blocks, a thread that goes on after the result was written). Wrap code you do not trust in a `Timeout` of your own.
|
|
79
79
|
- If the parent is interrupted while waiting (`Interrupt`, `Timeout`, `Thread#kill`), the child is asked to leave with `TERM`, killed with `KILL` if it is still there half a second later, and reaped, before the interruption proceeds, with no window between the fork and that guard. A second interruption during the reaping waits for it: no zombie is left.
|
|
80
80
|
- No file descriptor is left open after a call.
|
|
81
|
-
- Forks can be nested. The `TERM` an interrupted parent sends to an outer fork reaches it as a `SignalException`, which lets it ask its own children to leave and reap them in turn
|
|
81
|
+
- Forks can be nested. The `TERM` an interrupted parent sends to an outer fork reaches it as a `SignalException`, which lets it ask its own children to leave and reap them in turn, within the same half second. A fork that ignores `TERM` leaves orphans: the children of an outer one, when it is killed, and an inner one itself, as the fork above it is likely to be killed before it can kill it.
|
|
82
82
|
- A fork costs a few milliseconds; the pages of the parent are shared copy-on-write, and the cost grows with the size of the parent (about 2 ms at 50 MB, 20 ms at 700 MB).
|
|
83
83
|
|
|
84
84
|
## Things to know about fork
|
|
@@ -92,6 +92,10 @@ The value that comes back is a copy: an object returns as a new object, and its
|
|
|
92
92
|
- SimpleCov stores the coverage of a process from an `at_exit` handler, which `exit!` skips: the code the child runs is not in the parent's report. With `merge_subprocesses true` (`enable_for_subprocesses true` before SimpleCov 1.3), call `SimpleCov.result` in an `ensure` of the block to store the child's share; the parent merges it.
|
|
93
93
|
- The parent deserializes, with `Marshal`, what the child wrote; the child ran your block, which could reach the pipe and write anything. Aw isolates the side effects of code you trust; it is not a sandbox for code you do not. A hostile block can make `fork!` return or raise anything, make `fork?` answer `true`, choose the message of an `Aw::ChildError`, make the parent hold as much memory as it writes, run the parent's `marshal_load` methods and autoloads, and, from a continuation the parent captured (`callcc`), run the parent's code in the child: only the `status` of an `Aw::ChildError` comes from the system. Running as the parent's user, it can also signal the parent and leave processes behind; Aw kills and reaps the child only.
|
|
94
94
|
|
|
95
|
+
## Changes in 1.0.2
|
|
96
|
+
|
|
97
|
+
- Documentation: a fork that ignores `TERM` leaves orphans whether it is an outer one or an inner one, where 1.0.1 said so of an outer one only; Aw is tested on Linux and macOS, the BSDs no longer being named; what the block does outside the process happens.
|
|
98
|
+
|
|
95
99
|
## Changes in 1.0.1
|
|
96
100
|
|
|
97
101
|
- A process the block forked without a block, and which let the block return, no longer delivers a result in place of the child: it leaves without writing, as the child alone writes.
|
data/lib/aw.rb
CHANGED
|
@@ -7,7 +7,7 @@ require_relative "aw/fork"
|
|
|
7
7
|
# or re-raises what it raised. Side effects of the block on the process
|
|
8
8
|
# (mutations, globals, constants, the current directory, `ENV`, a crash)
|
|
9
9
|
# stay in the child; what it does outside, to files or to other processes,
|
|
10
|
-
#
|
|
10
|
+
# happens.
|
|
11
11
|
#
|
|
12
12
|
# The result travels through a pipe with `Marshal`, so it must be a
|
|
13
13
|
# marshalable value; a `Proc`, an `IO` or an instance of an anonymous class
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aw
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cyril Kato
|
|
@@ -26,6 +26,7 @@ licenses:
|
|
|
26
26
|
- MIT
|
|
27
27
|
metadata:
|
|
28
28
|
bug_tracker_uri: https://github.com/fixrb/aw/issues
|
|
29
|
+
changelog_uri: https://github.com/fixrb/aw#changes-in-102
|
|
29
30
|
documentation_uri: https://rubydoc.info/gems/aw
|
|
30
31
|
rubygems_mfa_required: 'true'
|
|
31
32
|
source_code_uri: https://github.com/fixrb/aw
|