-TODO: switch default keypad mode to cope for broken apps.
TODO: manpage 900mb update
TODO: safer command: keymap processing.
TODO: "slow" rendering mode for bidi and scripts
WISH: just for fun, do shade and tint with XRender.
5.2
+ - new option -pty-fd that makes the terminal a slave
+ that uses an existing pty for I/O instead of starting
+ a command.
- SYNCCVS. backported bugfixes done to rxvt
(sourceforge bugs #1028739, #1028732), except for
pts/%s fix as it seems to collide with freebsd,
reconf
genac
+doc/embed
+doc/pty-fd
doc/etc/rxvt-unicode.terminfo
doc/etc/rxvt-unicode.termcap
doc/menu/example.menu
--- /dev/null
+#!/usr/bin/perl
+
+# embed a rxvt inside another X app
+# see also pty-fd
+
+# doesn't handle sigchld
+
+use Gtk2;
+
+init Gtk2;
+
+my $window = new Gtk2::Window 'toplevel';
+
+my $frame = new Gtk2::Frame "embedded rxvt-unicode terminal";
+
+$window->add ($frame);
+
+my $rxvt = new Gtk2::DrawingArea;
+$frame->add ($rxvt);
+$frame->set_size_request (700, 400);
+$window->show_all;
+my $xid = $rxvt->window->get_xid;
+
+system "rxvt -embed $xid &";
+
+$window->show_all;
+
+main Gtk2;
--- /dev/null
+#!/usr/bin/perl
+
+use IO::Pty;
+use Fcntl;
+
+my $pty = new IO::Pty;
+fcntl $pty, F_SETFD, 0; # clear close-on-exec
+
+system "rxvt -pty-fd " . (fileno $pty) . "&";
+
+# now communicate with rxvt
+my $slave = $pty->slave;
+
+print $slave "hi! please enter something and press return (ctrl-d to exit):\n";
+
+while (<$slave>) {
+ print $slave "you entered: $_";
+}
+
<strong>secondaryScroll</strong>.
</dd>
<p></p>
-<dt><strong><a name="item__2dkeysym_2esym_3a_string"><strong>-keysym.</strong><em>sym</em>: <em>string</em></a></strong><br />
+<dt><strong><a name="item__2dkeysym_2esym_string"><strong>-keysym.</strong><em>sym</em> <em>string</em></a></strong><br />
</dt>
<dd>
Remap a key symbol. See resource <strong>keysym</strong>.
</dd>
<p></p>
-<dt><strong><a name="item__2dembed_3a_windowid"><strong>-embed</strong>: <em>windowid</em></a></strong><br />
+<dt><strong><a name="item__2dembed_windowid"><strong>-embed</strong> <em>windowid</em></a></strong><br />
</dt>
<dd>
Tells rxvt to embed it's windows into an already-existing window,
terminal. This works regardless of wether the <code>-embed</code> option was used or
not.</p>
</dd>
+<dd>
+<p>Here is a short Gtk2-perl snippet that illustrates how this option can be
+used (a longer example is in <em>doc/embed</em>):</p>
+</dd>
+<dd>
+<pre>
+ my $rxvt = new Gtk2::DrawingArea;
+ $...->add ($rxvt); # important to add it somewhere first
+ $rxvt->realize; # now it can be realized
+ my $xid = $rxvt->window->get_xid;</pre>
+</dd>
+<dd>
+<pre>
+ system "rxvt -embed $xid &";</pre>
+</dd>
+<p></p>
+<dt><strong><a name="item__2dpty_2dfd_fileno"><strong>-pty-fd</strong> <em>fileno</em></a></strong><br />
+</dt>
+<dd>
+Tells rxvt NOT to execute any commands or create a new pty/tty
+pair but instead use the given filehandle as the tty master. This is
+useful if you want to drive rxvt as a generic terminal emulator
+without having to run a program within it.
+</dd>
+<dd>
+<p>If this switch is given, rxvt will not create any utmp/wtmp
+entries and will not tinker with pty/tty permissions - you have to do that
+yourself if you want that.</p>
+</dd>
+<dd>
+<p>Here is a example in perl that illustrates how this option can be used (a
+longer example is in <em>doc/pty-fd</em>):</p>
+</dd>
+<dd>
+<pre>
+ use IO::Pty;
+ use Fcntl;</pre>
+</dd>
+<dd>
+<pre>
+ my $pty = new IO::Pty;
+ fcntl $pty, F_SETFD, 0; # clear close-on-exec</pre>
+</dd>
+<dd>
+<pre>
+ system "rxvt -pty-fd " . (fileno $pty) . "&";</pre>
+</dd>
+<dd>
+<pre>
+ # now communicate with rxvt
+ my $slave = $pty->slave;
+ while (<$slave>) { print $slave "got <$_>\n" }</pre>
+</dd>
<p></p></dl>
<p>
</p>
.\" ========================================================================
.\"
.IX Title "rxvt 1"
-.TH rxvt 1 "2005-02-16" "5.2" "RXVT-UNICODE"
+.TH rxvt 1 "2005-02-17" "5.2" "RXVT-UNICODE"
.SH "NAME"
rxvt\-unicode (ouR XVT, unicode) \- (a VT102 emulator for the X window system)
.SH "SYNOPSIS"
.IX Item "-ssr|+ssr"
Turn on/off secondary screen scroll (default enabled); resource
\&\fBsecondaryScroll\fR.
-.IP "\fB\-keysym.\fR\fIsym\fR: \fIstring\fR" 4
-.IX Item "-keysym.sym: string"
+.IP "\fB\-keysym.\fR\fIsym\fR \fIstring\fR" 4
+.IX Item "-keysym.sym string"
Remap a key symbol. See resource \fBkeysym\fR.
-.IP "\fB\-embed\fR: \fIwindowid\fR" 4
-.IX Item "-embed: windowid"
+.IP "\fB\-embed\fR \fIwindowid\fR" 4
+.IX Item "-embed windowid"
Tells @@RXVT_NAME@@ to embed it's windows into an already-existing window,
which enables applications to easily embed a terminal.
.Sp
can use file descriptors to communicate with the programs within the
terminal. This works regardless of wether the \f(CW\*(C`\-embed\*(C'\fR option was used or
not.
+.Sp
+Here is a short Gtk2\-perl snippet that illustrates how this option can be
+used (a longer example is in \fIdoc/embed\fR):
+.Sp
+.Vb 4
+\& my $rxvt = new Gtk2::DrawingArea;
+\& $...->add ($rxvt); # important to add it somewhere first
+\& $rxvt->realize; # now it can be realized
+\& my $xid = $rxvt->window->get_xid;
+.Ve
+.Sp
+.Vb 1
+\& system "@@RXVT_NAME@@ -embed $xid &";
+.Ve
+.IP "\fB\-pty\-fd\fR \fIfileno\fR" 4
+.IX Item "-pty-fd fileno"
+Tells @@RXVT_NAME@@ \s-1NOT\s0 to execute any commands or create a new pty/tty
+pair but instead use the given filehandle as the tty master. This is
+useful if you want to drive @@RXVT_NAME@@ as a generic terminal emulator
+without having to run a program within it.
+.Sp
+If this switch is given, @@RXVT_NAME@@ will not create any utmp/wtmp
+entries and will not tinker with pty/tty permissions \- you have to do that
+yourself if you want that.
+.Sp
+Here is a example in perl that illustrates how this option can be used (a
+longer example is in \fIdoc/pty\-fd\fR):
+.Sp
+.Vb 2
+\& use IO::Pty;
+\& use Fcntl;
+.Ve
+.Sp
+.Vb 2
+\& my $pty = new IO::Pty;
+\& fcntl $pty, F_SETFD, 0; # clear close-on-exec
+.Ve
+.Sp
+.Vb 1
+\& system "@@RXVT_NAME@@ -pty-fd " . (fileno $pty) . "&";
+.Ve
+.Sp
+.Vb 3
+\& # now communicate with rxvt
+\& my $slave = $pty->slave;
+\& while (<$slave>) { print $slave "got <$_>\en" }
+.Ve
.SH "RESOURCES (available also as long\-options)"
.IX Header "RESOURCES (available also as long-options)"
Note: `@@RXVT_NAME@@ \-\-help' gives a list of all resources (long
Turn on/off secondary screen scroll (default enabled); resource
B<secondaryScroll>.
-=item B<-keysym.>I<sym>: I<string>
+=item B<-keysym.>I<sym> I<string>
Remap a key symbol. See resource B<keysym>.
-=item B<-embed>: I<windowid>
+=item B<-embed> I<windowid>
Tells @@RXVT_NAME@@ to embed it's windows into an already-existing window,
which enables applications to easily embed a terminal.
terminal. This works regardless of wether the C<-embed> option was used or
not.
+Here is a short Gtk2-perl snippet that illustrates how this option can be
+used (a longer example is in F<doc/embed>):
+
+ my $rxvt = new Gtk2::DrawingArea;
+ $...->add ($rxvt); # important to add it somewhere first
+ $rxvt->realize; # now it can be realized
+ my $xid = $rxvt->window->get_xid;
+
+ system "@@RXVT_NAME@@ -embed $xid &";
+
+=item B<-pty-fd> I<fileno>
+
+Tells @@RXVT_NAME@@ NOT to execute any commands or create a new pty/tty
+pair but instead use the given filehandle as the tty master. This is
+useful if you want to drive @@RXVT_NAME@@ as a generic terminal emulator
+without having to run a program within it.
+
+If this switch is given, @@RXVT_NAME@@ will not create any utmp/wtmp
+entries and will not tinker with pty/tty permissions - you have to do that
+yourself if you want that.
+
+Here is a example in perl that illustrates how this option can be used (a
+longer example is in F<doc/pty-fd>):
+
+ use IO::Pty;
+ use Fcntl;
+
+ my $pty = new IO::Pty;
+ fcntl $pty, F_SETFD, 0; # clear close-on-exec
+
+ system "@@RXVT_NAME@@ -pty-fd " . (fileno $pty) . "&";
+
+ # now communicate with rxvt
+ my $slave = $pty->slave;
+ while (<$slave>) { print $slave "got <$_>\n" }
+
=back
=head1 RESOURCES (available also as long-options)
Turn on/off secondary screen scroll (default enabled); resource
secondaryScroll.
- -keysym.*sym*: *string*
+ -keysym.*sym* *string*
Remap a key symbol. See resource keysym.
- -embed: *windowid*
+ -embed *windowid*
Tells rxvt to embed it's windows into an already-existing window,
which enables applications to easily embed a terminal.
terminal. This works regardless of wether the "-embed" option was
used or not.
+ Here is a short Gtk2-perl snippet that illustrates how this option
+ can be used (a longer example is in doc/embed):
+
+ my $rxvt = new Gtk2::DrawingArea;
+ $...->add ($rxvt); # important to add it somewhere first
+ $rxvt->realize; # now it can be realized
+ my $xid = $rxvt->window->get_xid;
+
+ system "rxvt -embed $xid &";
+
+ -pty-fd *fileno*
+ Tells rxvt NOT to execute any commands or create a new pty/tty pair
+ but instead use the given filehandle as the tty master. This is
+ useful if you want to drive rxvt as a generic terminal emulator
+ without having to run a program within it.
+
+ If this switch is given, rxvt will not create any utmp/wtmp entries
+ and will not tinker with pty/tty permissions - you have to do that
+ yourself if you want that.
+
+ Here is a example in perl that illustrates how this option can be
+ used (a longer example is in doc/pty-fd):
+
+ use IO::Pty;
+ use Fcntl;
+
+ my $pty = new IO::Pty;
+ fcntl $pty, F_SETFD, 0; # clear close-on-exec
+
+ system "rxvt -pty-fd " . (fileno $pty) . "&";
+
+ # now communicate with rxvt
+ my $slave = $pty->slave;
+ while (<$slave>) { print $slave "got <$_>\n" }
+
RESOURCES (available also as long-options)
Note: `rxvt --help' gives a list of all resources (long options)
compiled into your version.
// unfortunately other programs are even more buggy and dislike
// being sent SIGWINCH, so only do it when we were in fact being
// resized.
- if (seen_resize)
+ if (seen_resize && cmd_pid)
kill (-cmd_pid, SIGWINCH);
}
MEvent.button = AnyButton;
options = DEFAULT_OPTIONS;
want_refresh = 1;
- cmd_pid = -1;
- pty.pty = pty.tty = -1;
priv_modes = SavedModes = PrivMode_Default;
TermWin.focus = 0;
TermWin.ncol = 80;
priv_modes |= PrivMode_scrollBar;
SavedModes |= PrivMode_scrollBar;
}
+
if (menubar_visible ())
{
priv_modes |= PrivMode_menuBar;
void
rxvt_term::run_command (const char *const *argv)
{
- if (!pty.get ())
- rxvt_fatal ("can't initialize pseudo-tty, aborting.\n");
+#if ENABLE_FRILLS
+ if (rs[Rs_pty_fd])
+ {
+ pty.pty = atoi (rs[Rs_pty_fd]);
+ fcntl (pty.pty, F_SETFL, O_NONBLOCK);
+ }
+ else
+#endif
+ if (!pty.get ())
+ rxvt_fatal ("can't initialize pseudo-tty, aborting.\n");
pty.set_utf8_mode (enc_utf8);
rxvt_get_ttymode (&tio, er);
+#if ENABLE_FRILLS
+ if (rs[Rs_pty_fd])
+ return;
+#endif
+
sw_chld.start (SIGCHLD);
#ifndef __QNX__
switch (cmd_pid = fork ())
{
case -1:
- rxvt_fatal ("can't fork, aborting.\n");
+ {
+ cmd_pid = 0;
+ rxvt_fatal ("can't fork, aborting.\n");
+ }
case 0:
init_env ();
#ifdef HAVE_UTMP_PID
int i;
#endif
- struct passwd *pwent = getpwuid (getuid ());
+ struct passwd *pwent = getpwuid (getuid ());
if (!strncmp (pty, "/dev/", 5))
pty += 5; /* skip /dev/ prefix */
#if 0
// TIOCSWINSZâ is supposed to do this automatically and correctly
if (cmd_pid) /* force through to the command */
- kill (cmd_pid, SIGWINCH);
+ kill (-cmd_pid, SIGWINCH);
#endif
}
void
rxvt_ptytty::privileges (rxvt_privaction action)
{
+ if (tty < 0)
+ return;
+
rxvt_privileges (RESTORE);
if (action == SAVE)
;//next_tty_action = IGNORE;
else
# endif
-
{
chown (name, getuid (), ttyconf.gid); /* fail silently */
chmod (name, ttyconf.mode);
# ifdef HAVE_REVOKE
revoke (name);
# endif
-
}
}
else
Rs_borderLess,
Rs_lineSpace,
Rs_embed,
+ Rs_pty_fd,
#endif
Rs_cutchars,
Rs_modifier,
STRG (Rs_saveLines, "saveLines", "sl", "number", "number of scrolled lines to save"),
#if ENABLE_FRILLS
STRG (Rs_embed, NULL, "embed", "windowid", "window id to embed terminal in"),
+ STRG (Rs_pty_fd, NULL, "pty-fd", "fileno", "file descriptor of pty to use"),
STRG (Rs_ext_bwidth, "externalBorder", "w", "number", "external border in pixels"),
STRG (Rs_ext_bwidth, NULL, "bw", NULL, NULL),
STRG (Rs_ext_bwidth, NULL, "borderwidth", NULL, NULL),