Bug 3928

Summary: Pty.cxx frysk::sys::Pty::setUpPtyForConsole uses system() calls to set tty properties
Product: frysk Reporter: Phil Muldoon <pmuldoon>
Component: generalAssignee: Andrew Cagney <cagney>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 2246    

Description Phil Muldoon 2007-01-26 19:02:57 UTC
This might call problems with SIGCHLD and Frysk. Code snippet below.

        char prefix[30] = "stty -F ";
        char *pts_name = ptsname(master);
        char cmd[60];
         
        if (pts_name != NULL)
        {
                strcat(prefix, pts_name);
                strcpy(cmd, prefix);
                strcat(cmd, " -icanon min 1");
                system(cmd);
    
                strcpy(cmd, prefix);
                strcat(cmd, " -echo");
                system(cmd);
        }
Comment 1 Chris Moller 2007-01-26 19:42:35 UTC
What the system() stuff below is doing is setting the way the tty works.  It
could be done w/o system() by using terminal control ops similar to the following:

{
  struct termios tio;

  if (0 > tcgetattr(fd, *tio)) return -1;

  tio.c_lflag |= ICANON | ECHO;
  tio.c_cc[VMIN] = 1;

  if (0 < tcsetattr(fd, TCSANOW, ,&tio)) return -1;

  return 0;
}

where fd is the file descriptor associated with pts_name.

There are a few other wrinkles that might be relevant, but they'd depend on what
else is going on.
Comment 2 Andrew Cagney 2007-02-19 21:40:06 UTC
Code deleted, instead use frysk.sys.termios to manipulate the terminal; for this
specific case, CLI already does the manipulations so call was redundant.

Index: frysk-gui/frysk/gui/monitor/ChangeLog
2007-02-19  Andrew Cagney  <cagney@redhat.com>

        * ConsoleWidget.java: Delete call to PseudoTerminal
        .setUpForConsole.

Index: frysk-imports/frysk/sys/ChangeLog
2007-02-19  Andrew Cagney  <cagney@redhat.com>

        * PseudoTerminal.java (setUpForConsole): Delete.
        * cni/PseudoTerminal.cxx: Ditto.

        * termios/: New directory.