python-3.6.zip added from Github

README.cosmo contains the necessary links.
This commit is contained in:
ahgamut 2021-08-08 09:38:33 +05:30 committed by Justine Tunney
parent 75fc601ff5
commit 0c4c56ff39
4219 changed files with 1968626 additions and 0 deletions

View file

@ -0,0 +1,34 @@
"""When called as a script, print a comma-separated list of the open
file descriptors on stdout.
Usage:
fd_stats.py: check all file descriptors
fd_status.py fd1 fd2 ...: check only specified file descriptors
"""
import errno
import os
import stat
import sys
if __name__ == "__main__":
fds = []
if len(sys.argv) == 1:
try:
_MAXFD = os.sysconf("SC_OPEN_MAX")
except:
_MAXFD = 256
test_fds = range(0, _MAXFD)
else:
test_fds = map(int, sys.argv[1:])
for fd in test_fds:
try:
st = os.fstat(fd)
except OSError as e:
if e.errno == errno.EBADF:
continue
raise
# Ignore Solaris door files
if not stat.S_ISDOOR(st.st_mode):
fds.append(fd)
print(','.join(map(str, fds)))

View file

@ -0,0 +1,7 @@
"""When called as a script, consumes the input"""
import sys
if __name__ == "__main__":
for line in sys.stdin:
pass

View file

@ -0,0 +1,7 @@
"""When ran as a script, simulates cat with no arguments."""
import sys
if __name__ == "__main__":
for line in sys.stdin:
sys.stdout.write(line)

View file

@ -0,0 +1,10 @@
"""When called with a single argument, simulated fgrep with a single
argument and no options."""
import sys
if __name__ == "__main__":
pattern = sys.argv[1]
for line in sys.stdin:
if pattern in line:
sys.stdout.write(line)

View file

@ -0,0 +1,15 @@
import signal, subprocess, sys, time
# On Linux this causes os.waitpid to fail with OSError as the OS has already
# reaped our child process. The wait() passing the OSError on to the caller
# and causing us to exit with an error is what we are testing against.
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
subprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
# Also ensure poll() handles an errno.ECHILD appropriately.
p = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
num_polls = 0
while p.poll() is None:
# Waiting for the process to finish.
time.sleep(0.01) # Avoid being a CPU busy loop.
num_polls += 1
if num_polls > 3000:
raise RuntimeError('poll should have returned 0 within 30 seconds')