Execl()ing xterm and stdin

This is a discussion on Execl()ing xterm and stdin within the C Programming forums, part of the General Programming Boards category; Okay, same school project as before. I know now that less will automatically read from stdin. I have an IPC ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    8

    Execl()ing xterm and stdin

    Okay, same school project as before. I know now that less will automatically read from stdin. I have an IPC pipe going into the stdin descriptor of this child process, which I can then execl less to read that data.

    However, I want to run less in a new terminal window. So, I execl xterm -hold -E less.

    The problem here is that xterm is closing the IPC pipe I have routed to stdin's descriptor. Any of you know a way to prevent it from doing that, or a workaround that doesn't involve writing the contents of the pipe to a file and calling less on it?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,555
    http://www.die.net/doc/linux/man/man7/pty.7.html
    http://www.die.net/doc/linux/man/man1/xterm.1.html
    xterms use pseudo terminals to communicate with the outside world, so they can get input from the window, not the stdin they inherited from the environment which started them.

    There does however seem to be some kind of API which allows you to interact with a given pseudo-terminal, but that's going to take quite a bit of reading to figure out.

    Never done it, so I've no idea what's really involved at this stage.

    Starting the xterm first, then figuring out how to run your other processes might be an easier alternative.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21