Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
redirect running process to another tty?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
JeroenV
Guru
Guru


Joined: 16 Jul 2002
Posts: 447
Location: Amsterdam / Hamburg

PostPosted: Sat Aug 03, 2002 4:48 pm    Post subject: redirect running process to another tty? Reply with quote

Hi,

I have a general *nix question (though running Gentoo of course :lol: )
(see subject)

Suppose, I have a proces "tar jcvf TheWorld /usr/" running in an Eterm with bash. Now suppose I want to restart X, this means my Eterm will die, and so will my tar.
Of course I could have done "nohup tar jcvf TheWorld /usr/ &" in the first place, but at that time I didn't know I would want to restart my X.

So my question: is there some way to stop the job from one shell, assigning it to another shell (say a virtual console) and then continue it in that shell?
Or maybe assign the whole shell to another terminal?

Cheers
_________________
Cheers 8)
Jeroen
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
May The Source be with you!
Back to top
View user's profile Send private message
b-llwyd
Guru
Guru


Joined: 24 Jul 2002
Posts: 302
Location: Uppsala, Sweden

PostPosted: Sat Aug 03, 2002 5:21 pm    Post subject: Reply with quote

Maybe this is what you are looking for --> screen?

I am not versed in the ways of screen myself, but I've got a vague understanding of its capabilities - it might do the trick. But I suppose you have to start screen first...and the question is - would you do it if you didn't think you'd need it? You can detach screen sessions and reattach them later, even from another computer (if youre running it on a server).
Back to top
View user's profile Send private message
JeroenV
Guru
Guru


Joined: 16 Jul 2002
Posts: 447
Location: Amsterdam / Hamburg

PostPosted: Sat Aug 03, 2002 6:42 pm    Post subject: Reply with quote

Thanks, but as far as I can tell (I've also quickly read the man-page) you're right about also having to start screen first. (I installed it and tried some stuff)
The closest command I could think of was
screen -D -R 9272.10.localhost
but it just started a new empty screen session...
9272 is the pid of my running process and it's running on pts/10. Note that any more verbose namings of the tty were considered syntax errors... :?:

Any more ideas anyone? :roll:

Cheers :)
_________________
Cheers 8)
Jeroen
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
May The Source be with you!
Back to top
View user's profile Send private message
Lasker
Guru
Guru


Joined: 17 Jul 2002
Posts: 445

PostPosted: Sat Aug 03, 2002 10:52 pm    Post subject: Reply with quote

Interesting question. I think it's all about job - control but I didn't find a solution here, only a bunch of new questions.
At first I cannot see how to transport job - control from one terminal to another.
Then I found the job related command 'disown', which unbounds a sleeping job from a given terminal.
But I couldn't find a way to reinvoke such a job - so what is 'disown' good for?

P.S.: It's rather OT here and better should move to the General Linux Forum...
Back to top
View user's profile Send private message
b-llwyd
Guru
Guru


Joined: 24 Jul 2002
Posts: 302
Location: Uppsala, Sweden

PostPosted: Sun Aug 04, 2002 9:43 am    Post subject: Reply with quote

I was reading a zsh manual, and found out that you can do
Code:
setopt NO_HUP

and after this, you dont have to worry about using nohup <command> & all the time,
<command> & will be enough, leaving the process running.
You would still have to add the & though ;)
Back to top
View user's profile Send private message
JeroenV
Guru
Guru


Joined: 16 Jul 2002
Posts: 447
Location: Amsterdam / Hamburg

PostPosted: Sun Aug 04, 2002 12:22 pm    Post subject: Reply with quote

Hey, thanks, that's neat. However, I'm beginning to fear that the problem has now shifted. this NO_HUP thing works, but has the same effect as disown which Lasker kindly made me aware of.
I.e., spawning zsh from bash, then running setopt NO_HUP and running a program and then exiting zsh will pass the process to bash, so far so good. Exiting this bash now has the same effect of disowning the process: it remains there, but stopped and with no tty assigned. I searched google and found this:
http://groups.google.com/groups?q=opposite+of+disown&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=slrnajr6aa.ih7.leej%40cafe.lan&rnum=2
So is this the end? Does it mean it's really impossible to "re-own" a process?
That's a cold shower for the mighty feeling of the root-password owner :(
Well, thanks anyway :) (and if someone knows a way, I'd still be very much interested)

Cheers :)
_________________
Cheers 8)
Jeroen
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
May The Source be with you!
Back to top
View user's profile Send private message
Lasker
Guru
Guru


Joined: 17 Jul 2002
Posts: 445

PostPosted: Sun Aug 04, 2002 1:11 pm    Post subject: Reply with quote

Jeroen, I recommend posting your entire question to that newsgroup (comp.os.linux.misc).
If there is any solution chances are high to get it from here.
I'm still interested in that problem, so let me know if you found something.
Good luck!

EDIT: Ahh, just saw you already did that...


Last edited by Lasker on Sun Aug 04, 2002 1:19 pm; edited 1 time in total
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Sun Aug 04, 2002 1:16 pm    Post subject: Reply with quote

b-llwyd wrote:
I was reading a zsh manual, and found out that you can do
Code:
setopt NO_HUP

and after this, you dont have to worry about using nohup <command> & all the time,
<command> & will be enough, leaving the process running.
You would still have to add the & though ;)


How can I use this feature?
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
b-llwyd
Guru
Guru


Joined: 24 Jul 2002
Posts: 302
Location: Uppsala, Sweden

PostPosted: Sun Aug 04, 2002 1:42 pm    Post subject: Reply with quote

Well, first of all, you would have to install zsh if you havent already
Code:
emerge zsh

Now you can try it out by simply typing zsh.
If you want to change your default shell to zsh, run the command chsh and follow the instructions.

Now when you're running zsh, put this in your ~/.zshrc file
Code:
setopt nohup

and it should work. All you have to do now to keep your
processes running is adding that & behind them, like:
Code:
sleep 3600 &

and that particular process will keep on going even if you log out of the shell you started it in.
(this command really doesn't do anything ... it just stays there for 3600 secs :) )

NB. This behaviour is also obtained by simply using these commands from bash (or any shell perhaps?):
Code:
nohup <command> &
Back to top
View user's profile Send private message
DArtagnan
l33t
l33t


Joined: 30 Apr 2002
Posts: 942
Location: Israel, Jerusalem

PostPosted: Sun Aug 04, 2002 1:49 pm    Post subject: Reply with quote

Isn't there any option like
Code:
setopt nohup
for bash?
_________________
All for one and one for All
--

MACPRO machine...
Back to top
View user's profile Send private message
Naan Yaar
Bodhisattva
Bodhisattva


Joined: 27 Jun 2002
Posts: 1549

PostPosted: Sun Aug 04, 2002 3:06 pm    Post subject: Reply with quote

The nohup, AFAIK, allows the process to ignore explicit SIGHUPs. Even without nohup, the job will not be killed by bash, tcsh when launched with a "<program> &" or by doing "^Z" after launch and then doing a "bg" to background the job. zsh behaves differently by default, I believe.
Back to top
View user's profile Send private message
b-llwyd
Guru
Guru


Joined: 24 Jul 2002
Posts: 302
Location: Uppsala, Sweden

PostPosted: Mon Aug 05, 2002 6:07 pm    Post subject: Reply with quote

As Naan Yaar mentioned here, you can apparently do (i tried it) this:
Code:

% <command>
% ^Z
% bg
% disown

and your process will continue to run in the background, although you can't access it. I tried with a simple
Code:
sleep 20 && touch /var/tmp/test.file

and it worked (doing it from console as root, logging out then back again, watching as the /var/tmp/test.file appeared before me)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum