# Is watch in FreeBSD 8 Stable broken?



## val (Jan 20, 2010)

Hi!

I discovered the following behavior while using watch:

```
#watch pts/2
```
everithing ok, try to reconnect(Ctrl+x):

```
Snoop device change by user request.
Enter device name [/dev/pts/2]:
watch: fatal: cannot attach to tty
```

I tryed to write pts/2, /dev/pts/2 ect., but no success. Google doesn't help me in this question.

Does anybody knows how to fix this error?


----------



## aragon (Jan 20, 2010)

It's working here.  Did you kldload snp(4)?


----------



## val (Jan 20, 2010)

aragon said:
			
		

> It's working here.  Did you kldload snp(4)?


It's work, but cannot reconnect after request :\
snp compiled in kernel

```
device snp
```


----------



## aragon (Jan 20, 2010)

Ah, yes.  Same is happening here.  Log a PR.


----------



## sixtydoses (Jan 20, 2010)

Same happening here, 8.0-RELEASE.


----------



## val (Jan 20, 2010)

PR submitted: misc/143017


----------



## phoenix (Jan 20, 2010)

Does it work if you use TTY values, instead of PTS values?  *watch ttyv1* for example.  Just curious if it's actually been updated to work with the PTS system.


----------



## DutchDaemon (Jan 20, 2010)

`# watch /dev/pts/0` works fine here on FreeBSD 8.0-STABLE #0: Tue Jan  5 15:08:55 CET 2010..


----------



## val (Jan 20, 2010)

DutchDaemon said:
			
		

> `# watch /dev/pts/0` works fine here on FreeBSD 8.0-STABLE #0: Tue Jan  5 15:08:55 CET 2010..


yes, watch /dev/pts/0 does work
What about reconnect to tty after user request (Ctrl+X)?


----------



## val (Jan 20, 2010)

phoenix said:
			
		

> Does it work if you use TTY values, instead of PTS values?  *watch ttyv1* for example.  Just curious if it's actually been updated to work with the PTS system.



Problem not in *watch ttyv1*, impossible to recnnect to snoop device after user request:

```
Snoop device change by user request.
Enter device name [/dev/ttyv0]:
watch: fatal: cannot attach to tty
```


----------



## DutchDaemon (Jan 20, 2010)

val said:
			
		

> yes, watch /dev/pts/0 does work
> What about reconnect to tty after user request (Ctrl+X)?



The usual:


```
Snoop device change by user request.
Enter device name [/dev/pts/0]: [I][enter][/I]
watch: fatal: cannot attach to tty
```

Arrow up, enter, and we're back in.


----------



## val (Jan 20, 2010)

DutchDaemon said:
			
		

> The usual:
> 
> 
> ```
> ...



Arrow up here generate ^[[A and nothing happened. :\
BTW, shell is tcsh (if it's important):

```
Snoop device change by user request.
Enter device name [/dev/ttyv0]:^[[A
watch: fatal: bad device name
```


----------



## DutchDaemon (Jan 20, 2010)

No, arrow up after the 'fatal' error, when you're returned to the shell. Well, *I* am returned to the shell anyway ...

SO:


```
Snoop device change by user request.
Enter device name [/dev/pts/0]: [B][I][enter][/I][/B]
watch: fatal: cannot attach to tty
[return to shell prompt]
[arrow up = last command] [enter]
```


----------



## aragon (Jan 21, 2010)

lol.  Yes, the workaround is simple, but it doesn't change the fact that there is a bug in the watch utility.  It either needs to be fixed or the reconnect feature needs to be removed.

To the OP, you could start watch with "-n" to disable the reconnect/switch feature.


----------



## DutchDaemon (Jan 21, 2010)

Damn, I thought I'd sussed it good


----------



## val (Jan 21, 2010)

exit to shell and rerun watch - it's clearly and too trivial


----------



## chrcol (Feb 9, 2010)

funny watch was buggy in 7.0 as well, I guess the dev's dont use watch as they manage to bug it in two x.0 releases in a row now.


----------



## lme@ (Feb 19, 2010)

You could nag ed@ if he can take a look at it. He was the last one who touched watch.c and eats tty code for breakfast.


----------

