Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[Cdt-launch-inbox] [Bug 248071] New: C/C++ Local Application launch does not properly initialize terminal session

https://bugs.eclipse.org/bugs/show_bug.cgi?id=248071  
Product/Component: CDT / cdt-launch
           Summary: C/C++ Local Application launch does not properly
                    initialize terminal session
           Product: CDT
           Version: 5.0
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: normal
          Priority: P3
         Component: cdt-launch
        AssignedTo: cdt-launch-inbox@xxxxxxxxxxx
        ReportedBy: mirko@xxxxxxxx
                CC: alain@xxxxxxx, anton.leherbauer@xxxxxxxxxxxxx,
                    martin.oberhuber@xxxxxxxxxxxxx


Build ID: I20080617-2000

Steps To Reproduce:
This problem surfaced in relation to bug 196337, but it can be reproduced with
regular C/C++ Local Application launches on Solaris. It severely hinders the
development of terminal-based applications with CDT on Solaris.
To reproduce:

1. Create and run a C/C++ Local Application launch that launches "/bin/bash -i"
(make sure that "Connect process input/output to a terminal" is enabled)
2. As the standard console will not pass Ctrl-C to the terminal, choose a
different interrupt character: for example, use "@" by typing "stty intr @" at
the shell prompt
3. Now use the cat command to copy from standard input to a file by typing "cat
>testfile" at the prompt
4. To exit the "cat" program, type the interrupt character "@" followed by
return (return is necessary because of line buffering)

==> Problem #1: cat should terminate because the "@" character should trigger
an interrupt equivalent to Ctrl-C, but nothing happens

5. Terminate the "cat" program by ending the input with Ctrl-D (which signals
the end of input and does get passed on by the console view)

==> Problem #2: instead of just terminating the "cat" program the shell itself
also gets terminated by the Ctrl-D

I believe the root of the problem is related to the session set-up in
exec_pty.c, line 99 (see
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.solaris/library/exec_pty.c?annotate=1.5&root=Tools_Project#l99):

        setpgid(getpid(), getpid());

The process is made a process group leader but the session is never registered
with the terminal API. Line 99 should probably read:

        tcsetpgrp(STDIN_FILENO, setsid());

I tried this modification but it caused trouble when calling stty, because
whereas stdin and stdout are connected to a proper terminal, stderr is
connected to a pipe (see line 86), which is not a terminal. When I removed the
pipe and redirected stderr directly to the pseudo-terminal's slave device,
problem #1 (process interruption) went away. As a negative side effect I
noticed that the console coloring for stdout and stderr got sometimes mixed up.
Problem #2 (Ctrl-D terminating not only the active process but also the parent
shell) still persisted after my change.

I am mainly working on Solaris so I don't know whether this sort of problem
affects other platforms as well. I started using the CDT Spawner for bug
196337, but the above described problem prevents local terminals from behaving
correctly under Solaris. Developers working on terminal-based applications for
Solaris will also be affected by this issue.


-- 
Configure bugmail: https://bugs.eclipse.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


Back to the top