OpenSolaris Solaris Forum  
     

Left Nav Register FAQ Members List Default Password Members List Linux Commands Search Today's Posts Mark Forums Read Right Nav

Left Container Right Container
 

Go Back   OpenSolaris Solaris Forum » Solaris General

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-27-2010, 12:53 PM
Unregistered
Guest
 
Posts: n/a
Default Getting error while using System PPPD

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...
Reply With Quote
Sponsored Links

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:49 PM.


Powered by vBulletin. Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.