Below I posted a small piece of my code. I'm not familiar with using this C function that's highlighted in red and my program generates the following when executed:
"10 [main] a.out 4488 _cygtls::handle_exceptions: Error while dumping state (probably corrupted stack)"
As of right now i'm not passing the command to the function, only the arguments after it. Any help would be great. Thanks in advance.
Code:
char *string = "ls *.c";
char *token;
int count = 0;
boolean FIRSTGLOB = TRUE; //ignore boolean, already been type def'ed
int status = 0;
glob_t globbuf;
token = strtok( input, " " );
command = token;
while( token != NULL ) //process arguments after command ( i.e. "*.c" )
{
token = strtok( NULL, " " );
arguments[ count ] = token;
count++;
}
//in this case count will = 1, and the only argument was "*.c", so arguments[] only contains
// "*.c" (should it also contain "ls"?)
for( i=0; i<count; i++ ) //call the glob function for the number of wildcard arguments found
{
if( !FIRSTGLOB ) //more than one wildcard argument was found
glob( arguments[i], GLOB_DOOFFS | GLOB_APPEND, NULL, &globbuf );
else //only a single wildcard argument
{
glob( arguments[i], GLOB_DOOFFS, NULL, &globbuf );
FIRSTGLOB = FALSE; //no longer the first "glob", could be more wildcards
}
}
status = execvp( cmd, &globbuf.gl_pathv[0] );