[GHC] #8844: Pseudo terminal and process-1.2.0.0
GHC
ghc-devs at haskell.org
Tue Mar 4 13:05:13 UTC 2014
#8844: Pseudo terminal and process-1.2.0.0
-------------------------------------+-------------------------------------
Reporter: ksamborski | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: libraries/process | Version: 7.6.3
Keywords: pty | Operating System: Unknown/Multiple
Architecture: Unknown/Multiple | Type of failure: None/Unknown
Difficulty: Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: |
-------------------------------------+-------------------------------------
Hello,
I'm writing simple app which execute process and communicate with it
via pseudo terminal. Here is some sample code:
import System.Posix.Terminal
import System.Process
main = do
(master, slave) <- openPseudoTerminal
hslave <- fdToHandle slave
hSetBuffering hslave NoBuffering
(_,_,_,ph) <- createProcess (shell "mc"){ env = Just [("TERM", "xterm")]
, std_in = UseHandle hslave
, std_out = UseHandle hslave
, std_err = UseHandle hslave
, close_fds = True
}
forkIO $ readTerm master -- my function which reads output from process
waitForProcess ph
The problem is that mc still wants some input from stdin but not
from slave terminal.
But when I changed function runIteractiveProcess from runProcess.c like
this:
...
/* Reset the SIGINT/SIGQUIT signal handlers in the child, if
requested
*/
if (reset_int_quit_handlers) {
struct sigaction dfl;
(void)sigemptyset(&dfl.sa_
mask);
dfl.sa_flags = 0;
dfl.sa_handler = SIG_DFL;
(void)sigaction(SIGINT, &dfl, NULL);
(void)sigaction(SIGQUIT, &dfl, NULL);
}
/********************************************************************************/
setsid(); //Make the current process a new session leader
ioctl(0, TIOCSCTTY, 1); //As the child is a session leader,
set the controlling terminal to be the slave side of the PTY
/********************************************************************************/
/* the child */
if (environment) {
// XXX Check result
execvpe(args[0], args, environment);
} else {
// XXX Check result
execvp(args[0], args);
}
childFailed(forkCommunicationFds[1], forkExecFailed);
...
it worked as expected, I'm not proposing patch or solution but is there
any chance to add support for pseudo terminals in the process library?
Maybe just add another record field in CreateProcess like pty :: Bool and
then call these two additional instructions in runIteractiveProcess?
Best regards,
Karol Samborski
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8844>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list