Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,393
    • Issues 4,393
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 378
    • Merge Requests 378
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8844

Closed
Open
Opened Mar 04, 2014 by ksamborski@trac-ksamborski

Pseudo terminal and process-1.2.0.0

Error:

AsyncCancelled

Original Trac source:

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
Trac metadata
Trac field Value
Version 7.6.3
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries/process
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#8844