software/unix

File Descriptors after fork()

When opening a file::

fcntl(fd, F_SETFD, FD_CLOEXEC);

In python, you can pass the close_fds argument to subprocess.Popen() to close all file descriptors just after fork().

date in seconds-since-epoch

From the command line:

date '+%s'