History log of /seL4-refos-master/libs/libmuslc/src/misc/forkpty.c
Revision Date Author Comments
# 814aae20 21-Dec-2014 Rich Felker <dalias@aerifal.cx>

overhaul forkpty function using new login_tty

based on discussion with and patches by Felix Janda. these changes
started as an effort to factor forkpty in terms of login_tty, which
returns an error and skips fd reassignment and closing if setting the
controlling terminal failed. the previous forkpty code was unable to
handle errors in the child, and did not attempt to; it just silently
ignored them. but this would have been unacceptable when switching to
using login_tty, since the child would start with the wrong stdin,
stdout, and stderr and thereby clobber the parent's files.

the new code uses the same technique as the posix_spawn implementation
to convey any possible error in the child to the parent so that the
parent can report failure to the caller. it is also safe against
thread cancellation and against signal delivery in the child prior to
the determination of success.


# c0fe5b9d 21-Jul-2011 Rich Felker <dalias@aerifal.cx>

check for fd exhaustion in forkpty

we cannot report failure after forking, so the idea is to ensure prior
to fork that fd 0,1,2 exist. this will prevent dup2 from possibly
hitting a resource limit and failing in the child process. fcntl
rather than dup2 is used prior to forking to avoid race conditions.


# 10d7561d 20-Apr-2011 Rich Felker <dalias@aerifal.cx>

properly create new session/controlling terminal in forkpty


# 4921ce08 20-Apr-2011 Rich Felker <dalias@aerifal.cx>

implement (nonstandard) forkpty