Quote:
Originally Posted by rkomar
It's hard to tell with the remote debugging, but it looks like the segfault occurs during the read() because m_pty_fd = -1. I think the function should probably check the file descriptor value first, but in the end, without the pty working properly, nothing correct is ever going to happen anyway, so maybe getting a segfault at that point isn't any worse than just failing gracefully.
|
Sounds impossible - read() has no business of segfaulting on a bad file descriptor at all, in that case it's supposed to return -1 and set 'errno' to EBADF - if this can't be relied on then there's a lot more to worry about on this platform than I'd ever have imagined:-(
But then I'm also surprised that you get to the get_shell_output() function if 'm_pty_fd' is negative - that's checked when the PTY is opened and on failure (or other problems) CloseApp() is called. Looks like my assumption that, like exit(), it would terminate the program immmediately, is wrong. I'll put something in that avoids this situation. Thanks for making me aware of this possibility!
Best regards, Jens
PS: The modified version is now available for download.