#: 8600 S3/Languages
04-Dec-90 20:55:54
Sb: #login shell tst prg
Fm: MAS 76336,3226
To: 76703,4230 (X)
PART 1 OF TEST PROGRAM
************************************************************************* Here
is a sample test program! Plese see "#### WRITE 3 ####": BS is not recognized
by the login shell.
*************************************************************************
/* os9exec() login and piping */
#include #include #include
extern int errno; extern char **environ; extern int os9fork();
main() { int i;
int c[2], std[3], pid, ret;
char buffer[2];
char *argblk[2];
char bs[2];
bs[0] = (char) 8;
argblk[0] = "/h0/cmds/login";
argblk[1] = 0;
if ((c[0] = open("/pipe",S_IREAD|S_IWRITE)) == -1)
{ printf("Unable to open() read pipe : #%d\n",errno);
exit(0);
}
if ((c[1] = open("/pipe",S_IREAD|S_IWRITE)) == -1)
{ printf("Unable to open() write pipe : #%d\n",errno);
exit(0);
}
std[0] = dup(0);
std[1] = dup(1);
std[2] = dup(2);
close(0);
dup(c[0]);
close(1);
dup(c[1]);
close(2);
dup(c[1]);
pid = os9exec(os9fork,argblk[0],argblk,environ,0,0,3);
close(0);
dup(std[0]);
close(std[0]);
close(1);
dup(std[1]);
close(std[1]);
close(2);
dup(std[2]);
close(std[2]);
if (pid == -1)
{ printf("\n*** Can't os9exec() ***\n");
exit(0);
}
for(i=0;i<5;i++) /* read from login pipe till pipe is empty */
{ for(;;)
{
ret = getstat(1,c[1]);
if (ret > 0)
{ read(c[1],buffer,1);
printf("SHELL OUTPUT CHR> %c : %x
|