[Bug 21946] New: stdin should not be read-only

Bug ID 21946
Summary stdin should not be read-only
Product lldb
Version unspecified
Hardware PC
OS All
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@cs.uiuc.edu
Reporter bruce.mitchener@gmail.com
Classification Unclassified

In ProcessLaunchInfo, there is this code:

            if (default_to_use_pty && (!in_path || !out_path || !err_path)) {
                if (m_pty->OpenFirstAvailableMaster(O_RDWR| O_NOCTTY, NULL, 0))
{
                    const char *slave_path = m_pty->GetSlaveName(NULL, 0);

                    if (!in_path) {
                        AppendOpenFileAction(STDIN_FILENO, slave_path, true,
false);
                    }

                    if (!out_path) {
                        AppendOpenFileAction(STDOUT_FILENO, slave_path, false,
true);
                    }

                    if (!err_path) {
                        AppendOpenFileAction(STDERR_FILENO, slave_path, false,
true);
                    }
                }
            }

Where the prototype of AppendOpenFileAction is:

    bool ProcessLaunchInfo::AppendOpenFileAction (int fd, const char *path,
bool read, bool write)

Unfortunately, some programs rely upon being able to write to stdin and work
fine when run normally, but fail when run under lldb.  I'm pretty sure that the
failure is due to this read-only stdin being created ... I've run into this
with libtermkey.

There's nothing in
[http://pubs.opengroup.org/onlinepubs/009695399/functions/stdin.html](http://pubs.opengroup.org/onlinepubs/009695399/functions/stdin.html) which says
stdin should be read-only (or that it should be writeable) and I'm not sure
what else other documents might say.