summaryrefslogtreecommitdiffstats
path: root/cmd-run-shell.c
AgeCommit message (Collapse)Author
2013-03-25Merge branch 'obsd-master'Thomas
2013-03-25Try to establish client for run-shell and if-shell if no -t.Nicholas Marriott
2013-03-25Extend jobs to support writing and use that for copy-pipe instead ofNicholas Marriott
popen, from Chris Johnsen.
2013-03-24Add a command queue to standardize and simplify commands that call otherNicholas Marriott
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-24Expand format variables in the run-shell and if-shell shell commands,Nicholas Marriott
from Thiago Padilha.
2013-03-22evbuffer_readline returns allocated storage, don't leak it.Nicholas Marriott
2013-03-22Add functions to allocate and free command contexts rather than doing itNicholas Marriott
all on the stack.
2013-03-21Extend jobs to support writing and use that for copy-pipe instead of popen,Nicholas Marriott
from Chris Johnsen.
2013-03-11Fix if-shell and run-shell if there are no sessions. Batted around throughNicholas Marriott
several people, finished off by Chris Johnsen.
2013-02-25Remove previousThomas Adam
2013-02-25Plug small memory leak in run-shellThomas Adam
Don't potentially leak the command to run were it to fail.
2013-02-23Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-codeNicholas Marriott
Conflicts: cmd-if-shell.c cmd-run-shell.c tmux.1
2013-02-23Add a command queue to standardize and simplify commands that call otherNicholas Marriott
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-02-23Expand format variables in the run-shell and if-shell shell commands, fromNicholas Marriott
Thiago Padilha.
2013-02-20evbuffer_readline returns allocated storage, don't leak it.Nicholas Marriott
2013-02-18Add functions to allocate and free command contexts rather than doing it all onNicholas Marriott
the stack.
2012-11-27Merge branch 'obsd-master'Thomas Adam
Sync from OpenBSD.
2012-11-27Allow cmd-run-shell to accept -t to specify the pane to display theNicholas Marriott
output, requested by Alexander Tsepkov.
2012-07-11Sync OpenBSD patchset 1151:Tiago Cunha
Make command exec functions return an enum rather than -1/0/1 values and add a new value to mean "leave client running but don't attach" to fix problems with using some commands in a command sequence. Most of the work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
2012-07-11Sync OpenBSD patchset 1150:Tiago Cunha
xfree is not particularly helpful, remove it. From Thomas Adam.
2012-07-11Make command exec functions return an enum rather than -1/0/1 values andNicholas Marriott
add a new value to mean "leave client running but don't attach" to fix problems with using some commands in a command sequence. Most of the work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
2012-07-10xfree is not particularly helpful, remove it. From Thomas Adam.Nicholas Marriott
2011-07-09Expand the Id keyword. Tiago Cunha
2011-02-15Sync OpenBSD patchset 855:Tiago Cunha
Simplify the way jobs work and drop the persist type, so all jobs are fire-and-forget. Status jobs now managed with two trees of output (new and old), rather than storing the output in the jobs themselves. When the status line is processed any jobs which don't appear in the new tree are started and the output from the old tree displayed. When a job finishes it updates the new tree with its output and that is used for any subsequent redraws. When the status interval expires, the new tree is moved to the old so that all jobs are run again. This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands of identical persistent jobs and high memory use (this can still be achieved by adding "sleep 30" but that is much less likely to happen by accident).
2011-01-26Simplify the way jobs work and drop the persist type, so all jobs areNicholas Marriott
fire-and-forget. Status jobs now managed with two trees of output (new and old), rather than storing the output in the jobs themselves. When the status line is processed any jobs which don't appear in the new tree are started and the output from the old tree displayed. When a job finishes it updates the new tree with its output and that is used for any subsequent redraws. When the status interval expires, the new tree is moved to the old so that all jobs are run again. This fixes the "#(echo %H:%M:%S)" problem which would lead to thousands of identical persistent jobs and high memory use (this can still be achieved by adding "sleep 30" but that is much less likely to happen by accident).
2011-01-07Sync OpenBSD patchset 829:Tiago Cunha
Clean up and simplify tmux command argument parsing. Originally, tmux commands were parsed in the client process into a struct with the command data which was then serialised and sent to the server to be executed. The parsing was later moved into the server (an argv was sent from the client), but the parse step and intermediate struct was kept. This change removes that struct and the separate parse step. Argument parsing and printing is now common to all commands (in arguments.c) with each command left with just an optional check function (to validate the arguments at parse time), the exec function and a function to set up any key bindings (renamed from the old init function). This is overall more simple and consistent. There should be no changes to any commands behaviour or syntax although as this touches every command please watch for any unexpected changes.
2011-01-04Clean up and simplify tmux command argument parsing.Nicholas Marriott
Originally, tmux commands were parsed in the client process into a struct with the command data which was then serialised and sent to the server to be executed. The parsing was later moved into the server (an argv was sent from the client), but the parse step and intermediate struct was kept. This change removes that struct and the separate parse step. Argument parsing and printing is now common to all commands (in arguments.c) with each command left with just an optional check function (to validate the arguments at parse time), the exec function and a function to set up any key bindings (renamed from the old init function). This is overall more simple and consistent. There should be no changes to any commands behaviour or syntax although as this touches every command please watch for any unexpected changes.
2010-08-09Sync OpenBSD patchset 741:Tiago Cunha
When changing so that the client passes its stdout and stderr as well as stdin up to the server, I forgot one essential point - the tmux server could now be both the producer and consumer. This happens when tmux is run inside tmux, as well as when piping tmux commands together. So, using stdio(3) was a bad idea - if sufficient data was written, this could block in write(2). When that happened and the server was both producer and consumer, it deadlocks. Change to use libevent bufferevents for the client stdin, stdout and stderr instead. This is trivial enough for output but requires a callback mechanism to trigger when stdin is finished. This relies on the underlying polling mechanism for libevent to work with whatever devices to which the user could redirect stdin, stdout or stderr, hence the change to use poll(2) over kqueue(2) for tmux.
2010-07-24When changing so that the client passes its stdout and stderr as well asNicholas Marriott
stdin up to the server, I forgot one essential point - the tmux server could now be both the producer and consumer. This happens when tmux is run inside tmux, as well as when piping tmux commands together. So, using stdio(3) was a bad idea - if sufficient data was written, this could block in write(2). When that happened and the server was both producer and consumer, it deadlocks. Change to use libevent bufferevents for the client stdin, stdout and stderr instead. This is trivial enough for output but requires a callback mechanism to trigger when stdin is finished. This relies on the underlying polling mechanism for libevent to work with whatever devices to which the user could redirect stdin, stdout or stderr, hence the change to use poll(2) over kqueue(2) for tmux.
2010-07-17Sync OpenBSD patchset 734:Tiago Cunha
Return the command client return code with MSG_EXIT now that MSG_ERROR and MSG_PRINT are unused. New clients should be compatible with old tmux servers but vice versa may print an error.
2010-07-11Return the command client return code with MSG_EXIT now that MSG_ERROR andNicholas Marriott
MSG_PRINT are unused. New clients should be compatible with old tmux servers but vice versa may print an error.
2010-06-06Sync OpenBSD patchset 705:Tiago Cunha
Don't die if the client has been detached when the job finishes, just don't display the output.
2010-05-25Don't die if the client has been detached when the job finishes, justNicholas Marriott
don't display the output.
2009-11-14Sync OpenBSD patchset 539:Tiago Cunha
Get rid of the ugly CMD_CHFLAG macro and use a const string (eg "dDU") in the command entry structs and a couple of functions to check/set the flags.
2009-11-13Get rid of the ugly CMD_CHFLAG macro and use a const string (eg "dDU") in theNicholas Marriott
command entry structs and a couple of functions to check/set the flags.
2009-11-08Sync OpenBSD patchset 493:Tiago Cunha
Switch jobs over to use a bufferevent.
2009-11-04Switch jobs over to use a bufferevent.Nicholas Marriott
2009-11-02Sync OpenBSD patchset 475:Tiago Cunha
Add a flag for jobs that shouldn't be freed after they've died and use it for status jobs, then only kill those jobs when status-left, status-right or set-titles-string is changed. Fixes problems with changing options from inside #().
2009-11-01Add a flag for jobs that shouldn't be freed after they've died and use it forNicholas Marriott
status jobs, then only kill those jobs when status-left, status-right or set-titles-string is changed. Fixes problems with changing options from inside #().
2009-10-12Sync OpenBSD patchset 385:Tiago Cunha
Remove a debugging leftover and add copyright.
2009-10-12Sync OpenBSD patchset 384:Tiago Cunha
Switch run-shell over to queue the command in the background like #().
2009-10-11Remove a debugging leftover and add copyright.Nicholas Marriott
2009-10-11Switch run-shell over to queue the command in the background like #().Nicholas Marriott
2009-09-20Sync OpenBSD patchset 335:Tiago Cunha
run-shell command to run a shell command without opening a window, sending stdout to output mode.
2009-09-20run-shell command to run a shell command without opening a window, sendingNicholas Marriott
stdout to output mode.