OILS / spec / show-fd-table.sh View on Github | oilshell.org

38 lines, 20 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./show-fd-table.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10source test/spec-runner.sh
11
12show-fd-table() {
13 echo " function in pid $$"
14 # Make it truly parallel
15 sleep 0.5
16 /usr/bin/env time --output /tmp/$$.txt -- spec/bin/show_fd_table.py "$@"
17}
18
19# Trying to recreate spec-runner problem with file descriptors.
20main() {
21 spec/bin/show_fd_table.py
22 echo
23
24 spec/bin/show_fd_table.py 2>/dev/null
25 echo
26
27 # File descriptor 3 is open!
28 /usr/bin/env time --output /tmp/task.txt -- spec/bin/show_fd_table.py
29 echo
30
31 # Cannot reproduce problem. What's the deal with descriptors 8 and 9? Oh
32 # maybe they have to be truly parallel.
33 echo 'XARGS'
34 seq 10 | xargs -n 1 -P 10 --verbose -- $0 show-fd-table
35 echo
36}
37
38"$@"