home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
TELECOM
/
OS9_Unix.lzh
/
RSHSRC
/
temp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-23
|
1KB
|
65 lines
/*---------------------------------------------------------------------*/
/*RSHDC hack down for testing*/
#include <signal.h>
#include <errno.h>
#define NULL (void *) 0
#define MAXB 512
#define in_skt 0
#define out_skt 1
#define err_skt 2
#define err_pipe 3
#define out_pipe 4
extern int os9forkc();
extern int errno;
/*
* The main program decides whether we are to fork to create an orphaned
* rshdc process, or whether we are the orphan!
*/
main(argc,argv,envp)
int argc;
char **argv, **envp;
{
int pid;
switch (**argv){
case 0: /* become the active orphan */
orphan(argc,argv,envp);
break;
default: /* respawn then orphan */
**argv=0;
pid=os9exec(os9forkc,"rshdc",argv,envp,0,0,3);
if(pid==-1) exit(_errmsg(errno,"Can't orphan"));
exit(0);
}
}
/*
* If this is the orphan go to business ...
*/
static int pid4=0;
orphan(argc,argv,envp)
int argc;
char **argv;
{
int cc;
char buff[MAXB];
write(err_skt,"Message on error path\l",22);
write(out_skt,"Input message: ",16);
errno=0;
cc=read(in_skt,buff,MAXB);
_errmsg(0,"%d bytes read from in_skt, errno=%d\l",cc,errno);
write(out_skt,buff,cc);
cc=read(err_skt,buff,1);
_errmsg(0,"%d bytes <%c> from err_skt\l",cc,buff[0]);
exit(0);
}