tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: hangup in close(2) after posix_openpt(3)



On Sun, Oct 18, 2015 at 11:33:43AM +0900, Izumi Tsutsui wrote:
 > > > > On Sat, Oct 17, 2015 at 03:23:44PM +0900, Izumi Tsutsui wrote:
 > > > > > I notice we can avoid the hangup in lwp_park() after exit(3)
 > > > > > by calling _exit(2) instead exit(3) in the parent canuum,
 > > > > > so I'll put it as a kludge for now.
 > > > > 
 > > > > Be careful, that bypasses all atexit handler. The reason why it might
 > > > > work is that this includes the fflush of stdin and stdout.
 > > > 
 > > > Do you have any idea about "hangup in lwp_park() after exit(3)"?
 > > > Is it a bug, or expected behavior?
 > > > 
 > > > Currently the hangup in lwp_park() (which can be killed only by kill -9)
 > > > is much annoying than _exit(2) kludge.
 > > 
 > > lwp_park is what happens when a threaded process is blocked, so my
 > > first guess would be an application-level deadlock.
 > 
 > Hmm, even after exit(3)?

All it takes is an atexit handler that takes a mutex, and an exit in
an unfortunate place...

 > Could posix_openpt(3) + fork(2)/execvp(3) (or curses(3)) without pthread
 > cause such deadlock?

I would be surprised if lwp_park appeared in such a deadlock.
Although, if you have a threaded process make sure you check all the
process's lwps; it might be that one is stuck on the tty while holding
a mutex needed by another one.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index