gc: use tempfile module to handle gc.pid file