Hi,
I am trying to use the Solaris system pppd by opening pseudo terminal pairs. I am getting
following error "tcgetattr: Invalid argument". I am unable to get root cause for it.
I enabled the kdebug flag of pppd. Still there is no enough information.
Here is the program which I am using..
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <termios.h>
#include <string.h>
int main()
{
int pseduoFd, argsIndex = 0;
char *args[8];
struct termios termInfo;
printf ("\n Test Programe \n");
printf("\n Opening Pseduo-Terminals In Unix System \n");
printf("\n ---------------------------------------- \n");
/* Opening Master Device Files */
pseduoFd = open("/dev/ptmx", O_RDWR|O_NOCTTY);
printf ("\n Pseduo Terminal Device Descriptor : %d", pseduoFd );
/* Grant Access To Slave */
if (grantpt(pseduoFd) < 0) {
close(pseduoFd);
return(-2);
}
/* Clear Slave's Lock Flag */
if (unlockpt(pseduoFd) < 0) {
close(pseduoFd);
return(-3);
}
printf("\n Pseduo Terminal Slave Device Name: %s \n", ptsname(pseduoFd) );
tcgetattr(pseduoFd, &termInfo);
printf("\n Error Number: %d -- %s \n", errno, strerror(errno));
/* Need To Spawn System PPPD */
/* Preparing The Arguments */
args[argsIndex++] = "/usr/bin/pppd";
args[argsIndex++] = ptsname(pseduoFd);
args[argsIndex++] = "-detach";
args[argsIndex++] = "asyncmap";
args[argsIndex++] = "0";
args[argsIndex++] = "logfile";
args[argsIndex++] = "/app2/vskumar/pppd/sun-ppp.log";
args[argsIndex++] = 0;
printf("\n Spwaning New Process: \n" );
int pid = fork();
switch(pid)
{
case 0:
//case of child
if( execv( args[0], args ) == -1 )
{
// perror("Unable to exec child pppd");
printf("Unable to exec child pppd");
exit(-1);
}
return -1;
break;
case -1:
//perror("Could not fork /usr/sbin/pppd");
printf("Could not fork /usr/sbin/pppd");
return -1;
break;
default:
//case of parent;
printf ("\n Parent Process Running \n");
while(1)
{
}
}
return 1;
}
Could you please help me what could be the wrong? I am not getting any problem while opeing the Pseudo Termina pairs...