forked from oils-for-unix/oils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eintr.sh
executable file
·47 lines (38 loc) · 1.3 KB
/
eintr.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
#
# Test out our modifications to posixmodule.c to handle EINTR.
#
# Usage:
# ./eintr.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
posix-test() {
PYTHONPATH=.:vendor EINTR_TEST=1 \
native/posix_test.py "$@"
}
test-read() { posix-test PosixTest.testRead; }
test-wait() { posix-test PosixTest.testWait; }
test-waitpid() { posix-test PosixTest.testWaitpid; }
test-write() { posix-test PosixTest.testWrite; }
# Conclusion: print CAN raise IOError with EINTR.
#
# It might be better to make our own functions:
#
# io.echo() # print()
# io.log() # print() to stderr
# NOTE: print() is a complicated function that ends up looking up
# sys.stdout.write(). So fixing write should fix print!
# But for simplicity, we could still get rid of print(). It's a complicated
# function with too many args.
test-print() { posix-test PosixTest.testPrint; }
# NOTES:
#
# - PEP 475 says that Python purposesly ignores EINTR on close() and dup2().
# The reason is due to multi-threaded programs: close() and dup2() change
# the descriptor table, so another thread could have reused the file
# descriptor in that time! This doesn't apply to the shell, so maybe we
# should handle them?
# - The parts of fcntl() we use don't appear to return EINTR. Not covered by
# PEP 475.
"$@"