Commit Graph

76 Commits

Author SHA1 Message Date
nicm
b185449d07 Fix a memory/fd leak reported by Tiago Cunha. 2014-01-09 21:20:45 +00:00
nicm
adc1f21eae Three small changes from Tiago Cunha:
- Check for truncation when copying path.
- Don't need to use a temporary buffer in screen_set_title.
- Include strerror in output when connecting to server fails.
2014-01-09 14:05:55 +00:00
benno
7624800ddc from nicm: : handle msgbuf_write() returning EAGAIN 2013-11-13 20:43:36 +00:00
nicm
99e3cbc526 Use format_get_command() and some spacing tweaks. 2013-10-10 12:35:30 +00:00
nicm
c1ccefc62d We accidentally haven't been using $TMUX to work out the session for a
while and in fact it is less useful that using the client ttyname. So
don't bother and don't pass it from the client. If we need it in future
it is in c->environ.
2013-10-10 12:29:35 +00:00
nicm
7936ce3874 Show session name in detached message. Requested by somebody a few
months ago who didn't bother testing it. But it works for me anyway.
2013-10-10 12:28:08 +00:00
nicm
b8b85fbb0c Don't look at string[length - 1] if length == 0. 2013-10-10 12:27:38 +00:00
nicm
282c5f9644 Alter how tmux handles the working directory to internally use file
descriptors rather than strings.

- Each session still has a current working directory.

- New sessions still get their working directory from the client that
  created them or its attached session if any.

- New windows are created by default in the session working directory.

- The -c flag to new, neww, splitw allows the working directory to be
  overridden.

- The -c flag to attach let's the session working directory be changed.

- The default-path option has been removed.

To get the equivalent to default-path '.', do:

        bind c neww -c $PWD

To get the equivalent of default-path '~', do:

        bind c neww -c ~

This also changes the client identify protocol to be a set of messages rather
than one as well as some other changes that should make it easier to make
backwards-compatible protocol changes in future.
2013-10-10 12:26:34 +00:00
nicm
10c38436aa Similarly for MSG_COMMAND - allow full imsg limit not arbitrary 2048. 2013-10-10 12:13:56 +00:00
nicm
6c093010e0 Remove CMD_SENDENVIRON. 2013-10-10 12:09:34 +00:00
Nicholas Marriott
d89b35e682 Use lockf which is more portable than flock, from Dagobert Michelsen. 2013-04-22 08:42:19 +00:00
Nicholas Marriott
88b92df849 We ignore SIGWINCH until ready, so send a MSG_RESIZE immediately when
becoming ready.
2013-03-25 11:38:57 +00:00
Nicholas Marriott
6fee3e9e4b Rename session idx to session id throughout and add $ prefix to targets
to use it, extended from a diff from George Nachman.
2013-03-25 10:11:45 +00:00
Nicholas Marriott
62db3c8efe Send DSC 1000p at the beginning of a -CC client's lifetime and ST and
the end, from George Nachman.
2013-03-25 10:03:24 +00:00
Nicholas Marriott
20636d956d Add a command queue to standardize and simplify commands that call other
commands and allow a command to block execution of subsequent
commands. This allows run-shell and if-shell to be synchronous which has
been much requested.

Each client has a default command queue and commands are consumed one at
a time from it. A command may suspend execution from the queue by
returning CMD_RETURN_WAIT and then resume it by calling cmd_continue() -
for example run-shell does this from the callback that is fired after
the job is freed.

When the command queue becomes empty, command clients are automatically
exited (unless attaching). A callback is also fired - this is used for
nested commands in, for example, if-shell which can block execution of
the client's cmdq until a new cmdq becomes empty.

Also merge all the old error/info/print functions together and lose the
old curclient/cmdclient distinction - a cmdq is bound to one client (or
none if in the configuration file), this is a command client if
c->session is NULL otherwise an attached client.
2013-03-24 09:54:10 +00:00
Nicholas Marriott
8d59b189cc No more lint means no more ARGSUSED. 2013-03-22 10:31:22 +00:00
Nicholas Marriott
2e43372d0b If stdin in the client is enable immediately, tmux will eat anything
sent to stdin before it is needed, which can be inconvenient (eg pasting
commands). Instead, start with stdin disabled and reuse MSG_STDIN from
server->client to mean that stdin should be enabled. Based on a diff
from Chris Johnsen.
2012-09-03 08:48:57 +00:00
Nicholas Marriott
84a4007b06 Change a log to fprintf that was missed last time around, from Tiago Cunha. 2012-08-27 21:35:11 +00:00
Nicholas Marriott
df912e3540 xfree is not particularly helpful, remove it. From Thomas Adam. 2012-07-10 11:53:01 +00:00
Nicholas Marriott
0f00c3b47a Actually write all the data to stdout/stderr. 2012-06-18 13:34:56 +00:00
Nicholas Marriott
2942eca895 Add a skeleton mode to tmux (called "control mode") that let's tmux
commands be sent and output received on stdout. This can be used to
integrate with other terminal emulators and should allow some other
things to be made simpler later. More to come so doesn't do much yet and
deliberately not documented.
2012-06-18 13:16:42 +00:00
Nicholas Marriott
196710e2d3 Simplify logging and just fprintf(stderr, ...) for early errors. 2012-05-25 08:28:10 +00:00
Nicholas Marriott
7a4679a17f Instead of passing stdin/stdout/stderr file descriptors over imsg and
handling them in the server, handle them in the client and pass buffers
over imsg. This is much tidier for some upcoming changes and the
performance hit isn't critical.

The tty fd is still passed to the server as before.

This bumps the tmux protocol version so new clients and old servers are
incompatible.
2012-05-21 18:27:42 +00:00
Nicholas Marriott
94795eb48e Add missing prototype. 2012-04-23 23:25:02 +00:00
Nicholas Marriott
d3e432069b Use an enum for client exit reasons, from George Nachman. 2012-04-23 23:18:43 +00:00
Nicholas Marriott
0edaa34bfd Add sys/file.h. 2012-03-24 11:23:19 +00:00
Nicholas Marriott
bf9e7a1c68 Move MSG_IDENTIFY to the last sent by the client, this will be needed by
control clients and irrelevant for others.
2012-03-19 08:42:06 +00:00
Nicholas Marriott
ac9ebc29a2 Use a lock file and flock() to serialize server start, avoids problems
when running a bunch of tmux from cron at the same time. Based on a diff
from Tim Ruehsen.
2012-03-09 09:57:40 +00:00
Nicholas Marriott
7954126dcd Add a -P option to detach to HUP the client's parent process (usually
causing it to exit as well).
2011-03-03 08:51:47 +00:00
Nicholas Marriott
69cb1f830e Move all calls to fcntl(...O_NONBLOCK) into a function and clear the
flag on the stdio file descriptors before closing them (fixes things
like "tmux ls && cat").
2011-01-08 01:52:36 +00:00
Nicholas Marriott
248fb14f08 Merge the before and after attach client code into one in client.c
(instead of two in tmux.c and client.c).
2010-10-18 20:00:02 +00:00
Nicholas Marriott
f56b4ec2ff Trying to set FD_CLOEXEC on every fd is a lost cause, just use
closefrom() before exec.
2010-10-16 08:31:55 +00:00
Nicholas Marriott
fc9f08235b Can't call event_del() without event_set() first - so call event_set()
when setting up the client.
2010-08-23 17:36:32 +00:00
Nicholas Marriott
5f5104e782 MSG_EXIT can now have a return code in the message, so check for that
size as well. Stops the client fatal()ing on exit.
2010-08-22 16:09:49 +00:00
Nicholas Marriott
76bbdeb586 Send all three of stdin, stdout, stderr from the client to the server, so that
commands can directly make use of them. This means that load-buffer and
save-buffer can have "-" as the file to read from stdin or write to stdout.

This is a protocol version bump so the tmux server will need to be restarted
after upgrade (or an older client used).
2010-06-28 22:10:42 +00:00
Nicholas Marriott
510ec3fb9e Fix problems with window sizing seen by Raghavendra D Prabhu when
starting tmux from .xinitrc.

One of the very few things the server relies on the client for now is to
pass through a message on SIGWINCH, but there is a condition where
potentially a SIGWINCH may be lost during the transition from unattached
(main.c) to attached (client.c). So trigger a size change immediately
after the client installs its SIGWINCH handler.

Also, when the terminal is resized, reset the scroll region and cursor
position. Previously, we were clearing our saved idea of these, but in
fact some terminals do not reset them on resize, so this caused problems
during redraw.

While here make a resize to the same size not cause a redraw and rename
the tmux.out output log file to include the tmux PID.
2010-06-05 16:47:11 +00:00
Nicholas Marriott
36c0871c23 This ioctl(TIOCGWINSZ) call is no longer necessary, the result is never
used and the server now does it later on the tty fd directly.
2010-06-05 16:29:45 +00:00
Joel Sing
72d1afa169 Catch SIGHUP and terminate if running as a client. This prevents clients
from being left hanging around when, for example, a SSH session is
disconnected.

ok nicm@
2010-05-12 15:05:39 +00:00
Nicholas Marriott
c4a2fdf15b Put this back in with the initialisation in the right order. 2010-05-04 17:28:16 +00:00
Nicholas Marriott
af5e0bd15a Revert last change, it appears to be broken somehow. 2010-05-04 08:48:06 +00:00
Nicholas Marriott
ec1d37b1b2 Make signal handler setup/teardown two common functions instead of six,
and reset SIGCHLD after fork to fix problems with some shells. From
Romain Francois.
2010-05-03 16:06:32 +00:00
Nicholas Marriott
15a64b805e Massive spaces->tabs and trailing whitespace cleanup, hopefully for the last
time now I've configured emacs to make them displayed in really annoying
colours...
2009-12-03 22:50:09 +00:00
Nicholas Marriott
4ca857e0e9 Remove a couple of unused arguments where possible, and add /* ARGSUSED */ to
the rest to reduce lint output.
2009-11-26 21:37:13 +00:00
Nicholas Marriott
a18a374d51 imsg_read returns ssize_t not int, pointed out by lint via deraadt. 2009-11-13 18:07:52 +00:00
Nicholas Marriott
9f47c6083a Don't return 1 unless there was actually a problem (signal/lost server) rather
than for all events (normal exit/detach/etc).
2009-11-10 15:47:48 +00:00
Nicholas Marriott
862fe15c32 Move some common code into a function. 2009-11-04 22:57:49 +00:00
Nicholas Marriott
abf3a5d50e Initial changes to move tmux to libevent.
This moves the client-side loops are pretty much fully over to event-based only
(tmux.c and client.c) but server-side (server.c and friends) treats libevent as
a sort of clever poll, waking up after every event to run various things.

Moving the server stuff over to bufferevents and timers and so on will come
later.
2009-11-04 20:50:11 +00:00
Nicholas Marriott
2a585dc4ed Leftover unused variable :-/. 2009-11-02 13:42:25 +00:00
Nicholas Marriott
42fd44f1db There isn't much point in doing lstat before connect so instead just do connect
and handle ENOENT from it which is a little tidier.
2009-11-02 13:41:25 +00:00
Nicholas Marriott
a8b1379ccb Clear signal flags /before/ taking action and continue afterwards to reduce
chance of dropping signals. Pointed out by deraadt@.
2009-10-26 21:38:18 +00:00