A terminal for Lilbug

Patrick Serru patrick at serru.net
Wed Sep 18 15:19:43 CEST 2013

Le mardi 17 septembre 2013, Andre Klärner a écrit :
> Hi Patrick,
> On Mon 16.09.2013 21:58:15, Patrick Serru wrote:
>> Le lundi 16 septembre 2013, vous avez écrit :
>>> On Mon, Sep 16, 2013 at 06:52:16AM -0500, Patrick Serru
>>> <patrick at serru.net> wrote:
>>> Have you looked at the -pty-fd option? That will both do away with the
>>> need to -e something, and it should work with urxvtc, too (but also
>>> urxvt of course).
>> Thank you for your response. I searched and searched. I found only two
>> references in the two pages given by Google. All but one is the content
>> of …/share/man/man7/urxvt.7, and the single other one was "Run a program
>> under a pty session". What I understoud is that there are a lot of
>> missunderstanding possible.
>> Let me rephrase the question: I would like to know how to write in C a
>> piece of code that: would open a graphical (separate) window running
>> urxvt and then
>> would open some bidirectional pipe to be able to
>>  - write to the standard input of that just opened urxvt running
>> graphical window and - read from the standard output of that urxvt
>> window.
> That is exactly what the -pty-fd option is supposed to do. The
> bidirectional pipe is in this case this file descriptor. The manpage has a
> nice example in perl that illustrates how to use urxvt for pushing and
> reading arbitrary stuff to a terminal window, it is only missing the part
> where it thats another binary and connects it to this terminal.
> As I needed a small challenge today I tried to grab some pieces of code and
> implement this in C. I really have to admit: despite I disliked perl for
> many years in cases like this one I really love it. 8 lines of perl versus
> 44 lines of C are pretty nice.
> I attached the small program, you need to compile it using "gcc -lutil
> urxvt-pty-test.c". Hopefully it won't burn your house, as this is my
> probably third program that actually compiles and runs. If anyone want's to
> critise it: please do.
> Regards, Andre
      Hi Andre, hi all,

      Thank you again:

~> gcc -o ~/bin/tst -lutil -lncurses -ltinfo \
~/bin/rxvt-unicode-9.18/src/urxvt-pty-test.c \
&& ~/bin/tst -geometry 80x24 -title 'pty-fd'
Child process: 4917
master fd: 3

      For the documentation, if you'll put some in the package,
the only little trap I fall in was that I built with non 
standard "--prefix=$HOME/.rxvt-9.18" so I had to modify line 41:

  if (execlp("/usr/bin/urxvt", "urxvt", "-pty-fd", strfd, NULL)==-1) {
  if (execlp("/home/pserru/.rxvt-9.18/bin/urxvt"…

and of course, I first wrote bad: "~/.rxvt-9.18/bin/urxvt"!


More information about the rxvt-unicode mailing list