TIP: Click on subject to list as thread! ANSI
echo: cis.os9.68000.osk
to: MAS 76336,3226 (X)
from: Kevin Darling (UG Pres) 76703,4227
date: 1990-10-26 17:09:32
subject: #7780-Help with C

#: 7782 S12/OS9/68000 (OSK)
    26-Oct-90  17:09:32
Sb: #7780-Help with C
Fm: Kevin Darling (UG Pres) 76703,4227
To: MAS 76336,3226 (X)

Hi Robert - I'm no UNIX guru, and others here may come up with a totally
different way of handling a login shell startup for you... but I think I can
help some on at least how pipes/forks are handled:

Under OS9, child processes inherit at least the parent's standard three paths
(in, out, err) at Fork time.  I believe under OS9/68K (OSK) you can change that
number, but we'll ignore that for now.

Therefore the trick is to have the parent process redirect any of those paths
_before_ forking a child.  One sequence might be:

 open pipe:(p0)         /* parent opens two pipe paths
 open pipe:(p1)
 dup   (0):(save0)      /* parent saves copy of stdin/out for later
 dup   (1):(save1)
 close (0), dup(p0)     /* redirect parent's stdin/out to pipes
 close (1), dup(p1)

 fork child             /* child starts up; inherits pipes as stdin/out

 close (0), dup(save0)  /* parent resets its original stdin/out
 close (save0)             and closes copies
 close (1), dup(save1)
 close (save1)
 ...
 write (p0)             /* parent uses pipe paths to comm with child
 read  (p1)

In this way, children don't have to know about redirection (altho they could
use gs_opts to check path device types, if wished). best - kev

SOURCE: compuserve via textfiles.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.