Use openpty for allocating pty on Darwin. Fix Bug#726 and Bug#5819.