tty: fix memleak in alloc_pid