Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close input/output handles when running in background (#489)
When we run in background mode, the child process inherits the stdin/stdout/stderr of the parent. That's good because we can print mount errors from the child and have them reach the parent. But once we're mounted and the parent exits, the child still holds onto those handles. This is bad if those handles are pipes, which are often used when trying to launch a daemon (e.g. Python subprocess.check_output). In that case, the pipes will never close and the caller will keep waiting for output on them forever. We need to close these handles once we're successfully daemonized. This will prevent us from seeing anything the process prints after they're closed, but from that point we should be logging anyway, so shouldn't be printing. Printing still works (doesn't panic or anything), just doesn't go anywhere. With this change, a Python script like import subprocess subprocess.check_output(['mount-s3', 'doc-example-bucket', '/bucket']) works correctly: once the mount has succeeded, it returns. Without this change, this program blocks until the bucket is unmounted. Signed-off-by: James Bornholt <[email protected]>
- Loading branch information