| 1 | #!/usr/bin/env bash
 | 
| 2 | #
 | 
| 3 | # Usage:
 | 
| 4 | #   ./show-fd-table.sh <function name>
 | 
| 5 | 
 | 
| 6 | set -o nounset
 | 
| 7 | set -o pipefail
 | 
| 8 | set -o errexit
 | 
| 9 | 
 | 
| 10 | source test/spec-runner.sh
 | 
| 11 | 
 | 
| 12 | show-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.
 | 
| 20 | main() {
 | 
| 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 | "$@"
 |