Organization: The Ohio State University Dept. of Computer and Info. Science
References: <By1C80.5t0@CAM.ORG>
Date: Sun, 22 Nov 1992 02:52:12 GMT
Lines: 54
In article <By1C80.5t0@CAM.ORG> vandry@CAM.ORG (Phillip Vandry) writes:
>That program I posted a while ago that forks a process and crashes when that
>process finishes -- well, I got it working. Turns out I was doing something
>that seems legal, but causes a crash much later.
>
Cool, I'll hold up on looking at your code then.
>But I have another problem now: After the child process dies, the main program
>reads from Standard Input, and I get a [1] + Stopped (tty input)
>
>There are two reasons why this should not occur:
>
>1. It's running in the foreground. Why stop a foreground process because it
> wants to read from Stamdard in?
>2. Standard input under normal circumstances (I run it from the console to
> debug but it's supposed to run off the modem port) is the modem port. Hey!
> I'd like to read from the modem port, please!
>
>Something weird: the child process itself runs a child process: gsh, and resumeswhen gsh quits. If I remove the code to run gsh (thus making the program pretty
>useless, but still :)) it never mentions [1] + Stopped (tty input)
>
>Because of this, it seems as though gsh somehow changes the environment of its
>parent process. Under no circumstances should a child be able to do that!
>
>Jawaid, you suggested creating a new process group, but (1) I don't see how thatwould help, and (2) How would that be done anyway?
>
when you get a stopped (tty input), in means a process not belonging to
foreground process group is trying to read input from the console. This
is protection to keep two programs from both trying to simultaneously
trying to read from the same input stream (standard input, in this case).
I suspect that your forked process is starting a 'gsh', but your main
process controls the tty. what you need to do is give your forked
process (which exeve's gsh) access to the tty by adding it to the process
group.
This is quite simple to do, since I already did it in the scriupt.asm
you were using as a base. You'll want to duplicate all the process group
calls in script.asm and use them in your program. The process group
call are calls such as tcnewgroup and similar...just find where they're
called in script.asm and use them in a similar or identical manner
in your program. when you do this, your process will join the process
group and will be able to legally use the standard i/o.
TIM MEEKINS Ask me about GNO/ME! - MultiTasking on a IIGS!