# Bring Process to foreground of another terminal



## andyzammy (Jul 17, 2011)

Hi,

I am currently in the middle of running portupgrade... I came back to my laptop, opened up the lid and it looked like the GUI had restarted (saw nvidia splash, no more terminal with my portupgrade).

I did a pu and i believe that it's still running (weired, because i thought all child processes would be killed if the GUI crashed):



```
# ps
  PID  TT  STAT      TIME COMMAND
 1468  v0- I      0:00.04 /usr/local/sbin/gdm-binary
 1658  v0  Is+    0:00.00 /usr/libexec/getty Pc ttyv0
 1659  v1  Is+    0:00.00 /usr/libexec/getty Pc ttyv1
 1660  v2  Is+    0:00.00 /usr/libexec/getty Pc ttyv2
 1661  v3  Is+    0:00.00 /usr/libexec/getty Pc ttyv3
 1662  v4  Is+    0:00.00 /usr/libexec/getty Pc ttyv4
 1663  v5  Is+    0:00.00 /usr/libexec/getty Pc ttyv5
 1664  v6  Is+    0:00.00 /usr/libexec/getty Pc ttyv6
 1665  v7  Is+    0:00.00 /usr/libexec/getty Pc ttyv7
73367   2  Is+    0:00.03 make
73375   2  I+     0:00.03 make config
73379   2  I+     0:00.00 [sh]
73391   2  R+    90:21.39 /usr/bin/dialog --checklist Options for en-freebsd-do
73901   1  I      0:00.00 su
73902   1  S      0:00.01 _su (csh)
74465   1  R+     0:00.00 ps
```

The portupgrade command isn't there but I'm sure that the make and make config is a prompt.. so the terminal that was originally displayed this is now gone, how do I bring this one to a new terminal so I can carry on?


----------



## graudeejs (Jul 17, 2011)

Use sysutils/tmux or sysutils/screen
With them you will be able to close GUI terminal, disconnect from net or whatever and later continue, without loosing progress


----------



## pelmen (Jul 17, 2011)

You can snoop control via

watch -W /dev/pts/<NUM>


----------



## andyzammy (Jul 17, 2011)

killasmurf86 said:
			
		

> Use sysutils/tmux or sysutils/screen
> With them you will be able to close GUI terminal, disconnect from net or whatever and later continue, without loosing progress



it sounds like i have to actually start the session up with these before being able to do that?




			
				pelmen said:
			
		

> You can snoop control via
> 
> watch -W /dev/pts/<NUM>



thanks, this sounds like what I'm after, but i get this:

```
# watch -W /dev/pts/2
watch: fatal: can't open device
```

thanks for the replys


----------



## Sebulon (Jul 17, 2011)

@andyzammy
You're doing it right. It's just that
# watch -W
needs root

/Sebulon


----------



## andyzammy (Jul 17, 2011)

Sebulon said:
			
		

> @andyzammy
> You're doing it right. It's just that
> # watch -W
> needs root
> ...



I'm definitely running it as root.


----------



## graudeejs (Jul 17, 2011)

andyzammy said:
			
		

> it sounds like i have to actually start the session up with these before being able to do that?



Yes. You can consider them as Window Managers for CLI apps 

Here's info about screen (I prefer tmux)
http://forums.freebsd.org/showthread.php?t=3599


----------



## andyzammy (Jul 18, 2011)

killasmurf86 said:
			
		

> Yes. You can consider them as Window Managers for CLI apps
> 
> Here's info about screen (I prefer tmux)
> http://forums.freebsd.org/showthread.php?t=3599



yeah, i found that but i can't use screen because i didn't launch the update with it, and watch is giving me that error i have there so there is nothing to do but sack it off and reboot/stop the process and start the update again? if that's the only way to do it will it affect/break anything?


----------



## wblock@ (Jul 18, 2011)

It will be hard to tell where it stopped, but there's not much else to be done.  Continue the upgrade and check everything afterwards with pkg_libchk from sysutils/bsdadminscripts.


----------



## UNIXgod (Jul 18, 2011)

killasmurf86 said:
			
		

> Yes. You can consider them as Window Managers for CLI apps



yup another alternative is dtach:
http://www.brain-dump.org/projects/dvtm/

As for running the cli as a wm check out dvtm:
http://www.brain-dump.org/projects/dvtm/

dvtm will work with gnu/screen and bsd/tmux

With some shell programming you can build a decent environment to ssh to.


----------



## poh-poh (Jul 18, 2011)

tmux and screen (in git) already have layout support. Using them together with dvtm seems redundant.


----------

