zsh-users
 help / color / mirror / code / Atom feed
* tostop && TTOU
@ 1999-12-12 11:22 Danny Dulai
  1999-12-12 22:58 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Danny Dulai @ 1999-12-12 11:22 UTC (permalink / raw)
  To: zsh-users

I'm trying to get TTOU generated in a script, without forcing the user to
stty tostop in the terminal controling shell.


i tried to set stty tostop in the script but that didnt work, so i tried to
set it in the script and then run the rest of the script in a subshell, but
that didnt work either.

if i run stty tostop in the top most shell, then the script gets TTOU.

if i run the script in a subshell (encapsulate the entire shell in ()'s),
then even the above solution fails to work.

Can anyone give me an explaination of how tostop and TTOU interact with
multiple layers of shells?

-- 
___________________________________________________________________________
Danny Dulai                                           Feet. Pumice. Lotion.
http://www.ishiboo.com/~nirva/                            nirva@ishiboo.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: tostop && TTOU
  1999-12-12 11:22 tostop && TTOU Danny Dulai
@ 1999-12-12 22:58 ` Bart Schaefer
  1999-12-12 23:34   ` Danny Dulai
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 1999-12-12 22:58 UTC (permalink / raw)
  To: Danny Dulai, zsh-users

On Dec 12, 11:22am, Danny Dulai wrote:
} Subject: tostop && TTOU
}
} I'm trying to get TTOU generated in a script, without forcing the user to
} stty tostop in the terminal controling shell.

You're going to have to give a few more details about the script.

In order to get a TTOU, the script itself must run in the background, or
it starts a background job; which one is it?

I played with this a bit, and if I run a script in the background which
attempts to do anything with stty, it gets TTOU even when the original
stty settings include -tostop.  I can only change the settings with a
foreground job.

} Can anyone give me an explaination of how tostop and TTOU interact with
} multiple layers of shells?

In shells with job control, which does not include scripts, zsh itself
ignores TTIN and TTOU; for other shells, it does not change the default
signal handling of TTIN or TTOU (which means they'll be ignored if the
parent process was ignoring them).

After forking (but, obviously, before exec'ing) an external process or
subshell, if job control is still active, zsh resets the TTIN and TTOU
handlers to the system default (which should be to stop the process).

But those aren't the only details involved.  Zsh also resets the tty
driver flags during various stages of ZLE processing, which can cause
changes made by other processes to be lost, and it changes (or doesn't)
the tty process group of subjobs in some cases, which may prevent them
from receiving tty signals (including TTIN/TTOU).

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: tostop && TTOU
  1999-12-12 22:58 ` Bart Schaefer
@ 1999-12-12 23:34   ` Danny Dulai
  0 siblings, 0 replies; 3+ messages in thread
From: Danny Dulai @ 1999-12-12 23:34 UTC (permalink / raw)
  To: zsh-users

On 12/12/99, Bart Schaefer said:
>On Dec 12, 11:22am, Danny Dulai wrote:
>} Subject: tostop && TTOU
>}
>} I'm trying to get TTOU generated in a script, without forcing the user to
>} stty tostop in the terminal controling shell.
>
>You're going to have to give a few more details about the script.
>
>In order to get a TTOU, the script itself must run in the background, or
>it starts a background job; which one is it?
>
>I played with this a bit, and if I run a script in the background which
>attempts to do anything with stty, it gets TTOU even when the original
>stty settings include -tostop.  I can only change the settings with a
>foreground job.

(~) % cat p
stty tostop

function o() {
    # so blank function doesnt complain
    foo=bar
}

trap o TTOU

helu=0
while :; do
        sleep 1
        echo $helu
        helu=$(($helu+1))
done

return 0


(~) % stty
speed 9600 baud; line = 0;
erase = ^H;
-brkint -imaxbel
tostop
(~) % /usr/local/src/zsh-3.1.5/Src/zsh p
0
1

zsh: 6096 suspended  /usr/local/src/zsh-3.1.5/Src/zsh p
(~) % bg
[1]  + continued  /usr/local/src/zsh-3.1.5/Src/zsh p
(~) % fg               <--- after waiting a few seconds
[1]  + running    /usr/local/src/zsh-3.1.5/Src/zsh p
6
7
8


Ok, thats the desired behavior.  The write() to stdout stops happening becuase
the SIGTTOU interrupts it i assume. But:


(~) % stty -tostop
(~) % /usr/local/src/zsh-3.1.5/Src/zsh p
0
1

zsh: 6112 suspended  /usr/local/src/zsh-3.1.5/Src/zsh p
(~) % bg
[1]  + continued  /usr/local/src/zsh-3.1.5/Src/zsh p
(~) % 2
3
4
5
6


The stty tostop in the begining of the script seems to have done nothing :(

This is all using zsh 3.1.6-pws-11.

What I'm trying to do is find out if the script is running in the background or
in the foreground. Another solution (other than TTOU) is to use TTIN, but I
can't figure out a way to do a nonblocking read from stdin from within a zsh
script. The TTIN solution is pretty easy if that read functionality exists,
because you dont have to mess with tty settings to get a TTIN.

-- 
___________________________________________________________________________
Danny Dulai                                           Feet. Pumice. Lotion.
http://www.ishiboo.com/~nirva/                            nirva@ishiboo.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-12-12 23:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-12 11:22 tostop && TTOU Danny Dulai
1999-12-12 22:58 ` Bart Schaefer
1999-12-12 23:34   ` Danny Dulai

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).