[lldb-dev] How to redirect stdin/out/err to different pty?

Piotr Rak piotr.rak at gmail.com
Sat Mar 22 12:36:36 PDT 2014


Hi,

It should.
Have you opened master pseudoterminal like?:

int fd = posix_openpt(flags); // open("/dev/ptmx") might work here too but
less portable;
grantpt(fd);
unlockpt(fd);

Depending on target you might need some bizarre ioctls here, but assuming
you are using Linux/FreeBSD/MacOSX
you should be fine.

If you had already master pseudo-terminal file descriptor you can skip
steps above.

You can use ptsname for master file descriptor it will return you name of
slave pseudo-terminal for your master.
Later you can pass name returned by ptsname(fd) as Launch arguments.

If above won't work you can try replacing Launch() call with ordinary fork,
and in child process:

slavefd = open(slavename, O_RDWR);

dup2(0, slavefd);
dup2(1, slavefd);
dup2(2, slavefd);

And see if that works alone for you...

Good luck,
/Piotr


2014-03-22 19:29 GMT+01:00 Eran Ifrah <eran.ifrah at gmail.com>:

> Hello,
>
> I am trying to use the C++ API with good success so far.
> I am now at a point where I want to redirect stdin/out/err of the inferior
> to my application (my application creates a separate pseudo terminal window)
>
> Looking at the SBTarget::Launch, I thought that simply passing
> "/dev/pts/<some-number>" as the 3rd, 4th and 5th argument will do the trick
> .. well, it did not.
> I am missing something basic here, can anyone shed some light please? or
> give an example (better) of how to achieve this?
>
> Thanks!
>
> --
> Eran Ifrah
> Author of codelite, a cross platform open source C/C++ IDE:
> http://www.codelite.org
> wxCrafter, a wxWidgets RAD: http://wxcrafter.codelite.org
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140322/3ec0aa8d/attachment.html>


More information about the lldb-dev mailing list