Discussion:
Option to start server without forking
Igor Bukanov
2015-01-20 13:09:43 UTC
Permalink
Hello,

is there an option to start tmux server so the process would not fork
and stay in the foreground, like screen -D -m? This will greatly
simplify running tmux from a process manager that do not support
forking services like supervisord.
Thomas Adam
2015-01-21 09:30:53 UTC
Permalink
Post by Igor Bukanov
Hello,
is there an option to start tmux server so the process would not fork
No, I did look at this many moons ago though:

https://github.com/ThomasAdam/tmux-cvs-archived/commit/4ae54388081f3802700eae2ebcd876efcb2714f5.diff

But it's not needed or wanted within tmux.
Post by Igor Bukanov
and stay in the foreground, like screen -D -m? This will greatly
simplify running tmux from a process manager that do not support
forking services like supervisord.
That would be the wrong solution.

-- Thomas Adam
Igor Bukanov
2015-01-21 10:40:10 UTC
Permalink
Consider running tmux on CoreOS. There when a user logs out from ssh,
that kills all user processes including any background tmux sessions.
The workaround is to run tmux server explicitly. For example, instead
of calling tmux one does something like:

systemd-run --unit "tmux-$USER" --service-type=forking tmux new-session -d
tmux attach

where systemd-run turns tmux process into a long-running service. Now,
this works as systemd supports forking services. However, If I want to
run tmux in a container, this option is not available. Container
managers like docker kills the container when the main process exits.
As tmux server cannot be invoked without forking, that requires to use
a script like:

tmux new-session -d
while true; do
sleep 1
tmux list-sessions > /dev/null 2>&1 || break
done

In reality the script is more complex as it need to propagate the
termination signals to tmux for a clean shutdown. It would be really
nice if all that can be replaced with just doing tmux -F or whatever.
Post by Thomas Adam
Post by Igor Bukanov
Hello,
is there an option to start tmux server so the process would not fork
https://github.com/ThomasAdam/tmux-cvs-archived/commit/4ae54388081f3802700eae2ebcd876efcb2714f5.diff
But it's not needed or wanted within tmux.
Post by Igor Bukanov
and stay in the foreground, like screen -D -m? This will greatly
simplify running tmux from a process manager that do not support
forking services like supervisord.
That would be the wrong solution.
-- Thomas Adam
Nicholas Marriott
2015-01-21 11:01:19 UTC
Permalink
This all seems like stuff that should be fixed in the other programs you
mention rather than worked around in tmux. Don't they have a way to
exempt a process from being killed? Programs have been forking like tmux
does for 40 years, it's not new.
Post by Igor Bukanov
Consider running tmux on CoreOS. There when a user logs out from ssh,
that kills all user processes including any background tmux sessions.
The workaround is to run tmux server explicitly. For example, instead
systemd-run --unit "tmux-$USER" --service-type=forking tmux new-session -d
tmux attach
where systemd-run turns tmux process into a long-running service. Now,
this works as systemd supports forking services. However, If I want to
run tmux in a container, this option is not available. Container
managers like docker kills the container when the main process exits.
As tmux server cannot be invoked without forking, that requires to use
tmux new-session -d
while true; do
sleep 1
tmux list-sessions > /dev/null 2>&1 || break
done
In reality the script is more complex as it need to propagate the
termination signals to tmux for a clean shutdown. It would be really
nice if all that can be replaced with just doing tmux -F or whatever.
Post by Thomas Adam
Post by Igor Bukanov
Hello,
is there an option to start tmux server so the process would not fork
https://github.com/ThomasAdam/tmux-cvs-archived/commit/4ae54388081f3802700eae2ebcd876efcb2714f5.diff
But it's not needed or wanted within tmux.
Post by Igor Bukanov
and stay in the foreground, like screen -D -m? This will greatly
simplify running tmux from a process manager that do not support
forking services like supervisord.
That would be the wrong solution.
-- Thomas Adam
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
tmux-users mailing list
https://lists.sourceforge.net/lists/listinfo/tmux-users
Igor Bukanov
2015-01-21 11:50:32 UTC
Permalink
On 21 January 2015 at 12:01, Nicholas Marriott
Post by Nicholas Marriott
This all seems like stuff that should be fixed in the other programs you
mention rather than worked around in tmux. Don't they have a way to
exempt a process from being killed? Programs have been forking like tmux
does for 40 years, it's not new.
I do not see non-forking option as a workaround. screen, sshd, cron
etc. all have a way to start without forking nowdays even if initially
they have not provided such option. I suppose in all these cases there
were useful deployment scenario that justified the option. In fact
non-forking support is so common that tools like Docker or supervisord
have not bothered with support for forking servers at all.
Balazs Kezes
2015-01-24 23:53:38 UTC
Permalink
Post by Nicholas Marriott
This all seems like stuff that should be fixed in the other programs
you mention rather than worked around in tmux. Don't they have a way
to exempt a process from being killed? Programs have been forking like
tmux does for 40 years, it's not new.
I have to concur with the OP. Even though you can work around for most
of the things but being able to start the server in the foreground does
simplify other workflows as well like starting tmux in debuggers or
sanitizers and so on.

And I also noticed that most daemons and background applications have a
flag to run themselves in the foreground.

Were such patch exist for tmux, would you guys accept? Not that I'm
volunteering, just wondering.
--
Balazs
Loading...