这篇教程C++ spawnvp函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中spawnvp函数的典型用法代码示例。如果您正苦于以下问题:C++ spawnvp函数的具体用法?C++ spawnvp怎么用?C++ spawnvp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了spawnvp函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: RunCommandstatic int RunCommand( const char *cmd ){ char *cmdnam; char *sp; const char **argv; int i; cmdnam = strdup( cmd ); argv = malloc( strlen( cmd ) * sizeof( char * ) ); i = 0; for( sp = cmdnam; sp != NULL; ) { while( *sp != '/0' && *sp == ' ' ) ++sp; argv[i++] = sp; sp = strchr( sp, ' ' ); if( sp != NULL ) { *sp = '/0'; sp++; } } argv[i] = NULL; i = (int)spawnvp( P_WAIT, cmdnam, argv ); free( cmdnam ); free( (void *)argv ); return( i );}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:26,
示例2: w32systemint w32system(const char *cp){ char argbuf[256]; char *argv[32]; char *tp; int argc; tp = argbuf; argc = 0; while(*cp) { while(*cp && (*cp == ' ')) cp++; if(*cp) { argv[argc++] = tp; if(*cp == '"') { cp++; while(*cp && (*cp != '"')) *tp++ = *cp++; if(*cp == '"') cp++; } else { while(*cp && (*cp != ' ')) *tp++ = *cp++; } *tp++ = '/0'; } } argv[argc] = NULL; return(spawnvp(P_WAIT, argv[0], argv));}
开发者ID:MarcNo,项目名称:lifelines,代码行数:28,
示例3: tclsh_maininttclsh_main(int ac, char **av){ char cmd[MAXPATH]; int ret; pid_t pid; sprintf(cmd, "%s/gui/bin/tclsh", bin); unless(executable(cmd)) { fprintf(stderr, "Cannot find the Tcl interpreter./n"); exit(1); } av[0] = cmd; spawn_tcl = 1; if ((pid = spawnvp(_P_NOWAIT, av[0], av)) < 0) { fprintf(stderr, "bk: cannot spawn %s/n", av[0]); } spawn_tcl = 0; if (waitpid(pid, &ret, 0) < 0) { return (126); } else if (!WIFEXITED(ret)) { return (127); } else { return (WEXITSTATUS(ret)); }}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:27,
示例4: execstatic void exec( char *program, char *param ) { static char *args[3]; int retcode; assert( program != NULL ); assert( param != NULL );#if DEBUG printf("*** Search '%s'/n", program );#endif fn_split( program ); args[0] = xfind( fn_make(".exe"), getrundir() ); args[1] = param; args[2] = NULL;#if DEBUG printf("*** Run '%s' '%s'/n", args[0], args[1] );#endif retcode = spawnvp( P_WAIT, args[0], (void *)args ); if ( retcode > 0 ) { fprintf( stderr, "/n'%s' exitcode = %d/n", program, retcode ); if (! get_option(OPT_KEEPRSP) ) unlink( RESPONSE ); exit( retcode ); } else if ( retcode < 0 ) { perror( program ); if (! get_option(OPT_KEEPRSP) ) unlink( RESPONSE ); exit(1); }}
开发者ID:doniexun,项目名称:OrangeC,代码行数:32,
示例5: ShellWrapper ShellWrapper() { int iReturn; iReturn = _pipe(iPipeIn_, 512, _O_TEXT | O_NOINHERIT); assert(iReturn != -1); iReturn = _pipe(iPipeOut_, 512, _O_TEXT | O_NOINHERIT); assert(iReturn != -1); //save old handle int iStdin = _dup(_fileno(stdin)); int iStdout = _dup(_fileno(stdout)); int iStderr = _dup(_fileno(stderr)); iReturn = _dup2(iPipeOut_[0], _fileno(stdin)); assert(iReturn == 0); iReturn = _dup2(iPipeIn_[1], _fileno(stdout)); assert(iReturn == 0); iReturn = _dup2(iPipeIn_[1], _fileno(stderr)); assert(iReturn == 0); char *arg[] = {"cmd.exe", "/Q", "/A", NULL}; iSubProcess_ = spawnvp(P_NOWAIT, arg[0], arg); //restore old handle iReturn = _dup2(iStdin, _fileno(stdin)); iReturn = _dup2(iStdout, _fileno(stdout)); iReturn = _dup2(iStderr, _fileno(stderr)); }
开发者ID:caicry,项目名称:my-windows-sdk,代码行数:28,
示例6: os_startpstatic int os_startp (const char *shell, const char *command, const char *parm) { if (parm) { char *argv[256],*par=strdup(parm),*p,i=0; argv[i++]=strdup(shell); argv[i++]=strdup("/c"); argv[i++]=strdup(command); p=strtok(par," "); while(p) { argv[i++]=strdup(p); p=strtok(0," "); } argv[i]=0; spawnvp (P_WAIT,shell,argv); i=0; while(argv[i])free(argv[i++]); free(par); } else { spawnlp (P_WAIT, (char *) shell, (char *) shell, "/c", (char *) command, (char *) 0); } return 0;}
开发者ID:OS2World,项目名称:UTIL-SHELL-Midnight_Commander,代码行数:28,
示例7: msc_systemstatic int msc_system (const char *s) { char *par[10]; int i = 0; char *p = (char *)b_cm__; (void)strcpy(p,s); while (*p==' ') p++; /* skip leading blanks */ while (*p!='/0') { par[i++] = p; while (*p!=' ' && *p!='/0') p++; /* search next blank */ if (*p==' ') { *p = '/0'; /* store null char */ p++; while (*p==' ') p++; /* skip leading blanks */ } } par [i] = NULL ; return spawnvp (P_WAIT, par[0],par ) ; }
开发者ID:skempken,项目名称:interverdikom,代码行数:25,
示例8: execvp_win32static int execvp_win32(const char *prog, char **argv){ int ret = spawnvp(P_NOWAIT, prog, (const char *const*)argv); if (-1 == ret) return ret; cwait(&ret, ret, WAIT_CHILD); exit(ret);}
开发者ID:raldoni,项目名称:tcc,代码行数:8,
示例9: mainmain(int argc, char *argv[]){ clock_t clock(),starttime; int status, i; if (argc < 2) { printf("Time execution of a command./nUse:/n/ttimer command/n"); exit(1); } argv[argc] = 0; /* terminate with a 0 (unportable method) */ starttime = clock();/*** This block added to keep arguments with embedded whitespace from getting** broken up when timing is done. A *nix version should be a bit different.** Also, the assignment to argv[i] technically isn't portable, but I don't** know of an implementation where it causes a problem. <JC>*/ for (i=1;i<argc;i++) { if (NULL != strchr(argv[i], ' ')) { size_t len = strlen(argv[i]+3); char *temp = malloc(len); strcpy(temp+1, argv[i]); temp[0] = '"'; temp[len-2] = '"'; temp[len-1] = '/0'; argv[i] = temp; } }/* This reduces memory usage with MS compilers by releasing unused heap. * Watcom may support it as well, but I'm not sure. */#if defined(_QC) || defined(_MSC_VER) _heapmin();#endif status = spawnvp(0,argv[1],SVP_CAST(argv + 1)); starttime = clock() - starttime; if (status == -1) { printf("'%s' failed to execute/n",argv[1]); exit(1); }#if !defined(__TURBOC__) printf("Elapsed time = %d.%02d seconds/n",(int) (starttime/CLK_TCK), (int) (starttime%CLK_TCK));#else printf("Elapsed time = %.2f seconds/n", starttime/CLK_TCK);#endif if (status != 0) printf("--- errorlevel %d/n",status); /* exit(0); changed to `return 0;' to reduce program size (minutely) * and possibility or warnings that main doesn't return a value. */ return 0;}
开发者ID:Eric-Schnipke,项目名称:snippets,代码行数:58,
示例10: modsys_execstatic int modsys_exec( INSTANCE * my, int * params ){ int mode = params[0]; char * filename = ( char * ) string_get( params[1] ); int argc = params[2]; char ** argv; int n = 0;#ifndef WIN32 pid_t child;#endif int status = -1; // fill argv argv = ( char ** ) calloc( argc + 2, sizeof( char * ) ); argv[0] = filename; for ( n = 0; n < argc; n++ ) argv[n + 1] = ( char * ) string_get((( int * )( params[3] ) )[n] ); // Execute program#ifdef WIN32 status = spawnvp( mode, filename, ( const char ** )argv );#else if (( child = fork() ) == -1 ) { //Error status = -1 ; } else if ( child == 0 ) { execvp( filename, ( const char ** )argv ); exit(-1); } else { /* father */ switch ( mode ) { case _P_WAIT: if ( waitpid( child, &status, WUNTRACED ) != child ) status = -1; else status = (int)(char)WEXITSTATUS(status); break; case _P_NOWAIT: status = child; break; } }#endif // Free resources string_discard( params[1] ); if ( argv ) free( argv ); return ( status ) ;}
开发者ID:GarethNelson,项目名称:BennuGD,代码行数:57,
示例11: mainint main(int argc,char *argv[]){clock_t start,end;FILE *fp;int j;char bb = 'f';float var;char aa[45]="The time that complies the program is : ";cout << "Command line arguments:/n/n";for (int i = 0; i < argc; ++i){ cout << "Argument [" << i << "] : " << argv[i] << '/n';} cout << "Measuring the time that needs to comply program [" << argv[i-1] << ".cpp" << ']' << "/n/n";for(j=0;j<argc;++j){ if((argv[j][0]=='-') && (argv[j][1]=='o')) { fp=fopen(argv[j+1],"w"); bb = 't'; } if((argv[j][0]=='b') && (argv[j][1]=='c') && (argv[j][2]=='c')) argv=argv+j;}start = clock();int result = spawnvp(P_WAIT,"bcc",argv);end = clock();var = (end - start) / CLK_TCK;if (bb == 't'){ fprintf(fp,"%s",aa); fprintf(fp,"%8.3f %s",var,"second(s)"); fclose(fp);}if ((result != -1) && (bb != 't')){ cout << "The time that complies the program is : " << var << " second(s)" << '/n';}if (result == -1){ perror("execution error");} return result;}
开发者ID:Abhay147,项目名称:BIN,代码行数:57,
示例12: nmake/* * Spawn the Watcom wmake. Returns NMAKE_ERROR if wmake returned a bad * status code or if it could not be spawned, or else NMAKE_SUCCESS if * everything went smoothly. */static int nmake( const OPT_STORAGE *cmdOpts, CmdLine *cmdLine )/**************************************************************/{ char ** args; int rc; int count; char * cwd; char flagstmp[32] = {0}; /*** get value for MAKEDIR field ***/ cwd = getcwd( NULL, 0 ); /*** construct MAKEFLAGS field ***/ if( cmdOpts->a ) strcat(flagstmp, "A"); if( cmdOpts->c ) strcat(flagstmp, "C"); if( cmdOpts->d ) strcat(flagstmp, "D"); if( cmdOpts->e ) strcat(flagstmp, "E"); if( cmdOpts->nologo ) strcat(flagstmp, "L"); if( cmdOpts->n ) strcat(flagstmp, "N"); if( cmdOpts->p ) strcat(flagstmp, "P"); if( cmdOpts->r ) strcat(flagstmp, "R"); if( cmdOpts->s ) strcat(flagstmp, "S"); if( cmdOpts->u ) strcat(flagstmp, "U"); if( cmdOpts->y ) strcat(flagstmp, "Y"); /*** pass builtin macros to wmake, so nmake wrapper gets called in recursive actions ***/ AppendFmtCmdLine( cmdLine, NMAKE_OPTS_SECTION, "MAKE=/"%s/"", "nmake" ); AppendFmtCmdLine( cmdLine, NMAKE_OPTS_SECTION, "MAKEDIR=/"%s/"", cwd ); AppendFmtCmdLine( cmdLine, NMAKE_OPTS_SECTION, "MAKEFLAGS=/"%s/"", flagstmp ); /*** merge commands ***/ AppendCmdLine( cmdLine, NMAKE_PROGNAME_SECTION, MAKE ); args = MergeCmdLine( cmdLine, INVALID_MERGE_CMDLINE ); /*** Spawn the wmake ***/ if( cmdOpts->showwopts ) { for( count=0; args[count]!=NULL; count++ ) { fprintf( stderr, "%s ", args[count] ); } fprintf( stderr, "/n" ); } if( !cmdOpts->noinvoke ) { rc = spawnvp( P_WAIT, MAKE, (const char **)args ); if( rc != 0 ) { if( rc == -1 || rc == 255 ) { FatalError( "Unable to execute '%s'", MAKE ); } else { return( NMAKE_ERROR ); } } } DestroyCmdLine( cmdLine ); return( NMAKE_SUCCESS );}
开发者ID:Ukusbobra,项目名称:open-watcom-v2,代码行数:60,
示例13: Spawnvpint Spawnvp(PCStr(what),PCStr(path),const char *const av[]){ int pid; if( DontFork ) { return -1; } SpawnWhat = what; MyPID = 0; pid = spawnvp(SPAWN_P_NOWAIT,path,av); return pid;}
开发者ID:Nervous-,项目名称:Psiphon3-for-Linux,代码行数:11,
示例14: LineOutputbool CDebuggerWin::CommandExecute(int argc, char **argv){ if(argc<2) { LineOutput("Invalid number of arguments"); return false; } else { spawnvp(_P_WAIT,argv[1],&argv[1]); } return true;}
开发者ID:alexthissen,项目名称:handy-fork,代码行数:13,
示例15: start_screensaver/* screen saver handler */static BOOL start_screensaver( void ){ if (using_root) { const char *argv[3] = { "xdg-screensaver", "activate", NULL }; int pid = spawnvp( _P_DETACH, argv[0], argv ); if (pid > 0) { WINE_TRACE( "started process %d/n", pid ); return TRUE; } } return FALSE;}
开发者ID:bpon,项目名称:wine,代码行数:15,
示例16: mainvoid main( int argc, char **argv ){ int rc; TIMESTAMP time; if( argc <= 1 ) { printf( "Usage: %s program [program args]/n", argv[0] ); exit( EXIT_SUCCESS ); } init(); rc = spawnvp( P_WAIT, argv[1], (const char**)&argv[1] ); fini( &time ); printf( "%s: %dms, %dns/n", argv[1], time.millisecs, time.nanosecs ); exit( rc );}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:15,
示例17: run/*---------------------------------------------------------------------*/static int run(char *line, bool isvc){ char *nargv[10000]; char *ptr = line; int i; for ( i=0; i < 10000-1; i++ ) { while ( *ptr == ' ' || *ptr == '/t' ) ptr++; if ( *ptr == '/0' ) break; if ( *ptr == '"' || *ptr == '/'' ) { char lim = *ptr++; nargv[i] = ptr; while ( *ptr != lim && *ptr != '/0' ) { if ( *ptr == '//' && (*ptr == '"' || *ptr == '/'') ) memmove(ptr, ptr+1, strlen(ptr)); ptr++; } } else { nargv[i] = ptr; while ( *ptr != ' ' && *ptr != '/t' && *ptr != '/0' ) ptr++; } if ( *ptr != '/0' ) *ptr++ = '/0'; } nargv[i] = NULL; i = spawnvp(P_WAIT, nargv[0], nargv); if ( i != 0 ) { if ( i == -1 ) perror("exec error"); else printf("ld error: '%s' exit with code %d/n", nargv[0], i); exit(3); } else if ( isvc ) { remove_exp_and_lib(nargv); } return 0;}
开发者ID:nealey,项目名称:vera,代码行数:49,
示例18: link/* * Link any object and library files. Returns LINK_NOACTION if there was no * file to compile, LINK_ERROR if the linker returned a bad status code or * if the compiler could not be spawned, or else LINK_SUCCESS if everything * went smoothly. */static int link( const OPT_STORAGE *cmdOpts, CmdLine *linkCmdLine )/*****************************************************************/{ char ** args; char * filename; int fileType; int numFiles; int rc; char * defFile; char * prevDefFile = NULL; cmdOpts = cmdOpts; /*** Process all object and library file names ***/ for( numFiles=0; ; numFiles++ ) { filename = GetNextFile( &fileType, TYPE_OBJ_FILE, TYPE_LIB_FILE, TYPE_RES_FILE, TYPE_INVALID_FILE ); if( filename == NULL ) break; AppendCmdLine( linkCmdLine, CL_L_FILENAMES_SECTION, filename ); } /*** Process .def files ***/ for( ;; ) { defFile = GetNextFile( NULL, TYPE_DEF_FILE, TYPE_INVALID_FILE ); if( defFile == NULL ) break; if( prevDefFile != NULL ) { Warning( "Overriding %s with %s", prevDefFile, defFile ); } prevDefFile = defFile; }; if( prevDefFile != NULL ) { AppendFmtCmdLine( linkCmdLine, CL_L_OPTS_SECTION, "/DEF:%s", prevDefFile ); } else { if( numFiles == 0 ) return( LINK_NOACTION ); } /*** Spawn the linker ***/ AppendCmdLine( linkCmdLine, CL_L_PROGNAME_SECTION, LINKER ); args = MergeCmdLine( linkCmdLine, INVALID_MERGE_CMDLINE ); rc = spawnvp( P_WAIT, LINKER, (const char **)args ); if( rc != 0 ) { if( rc == -1 || rc == 255 ) { FatalError( "Unable to execute '%s'", LINKER ); } else { return( LINK_ERROR ); } } return( LINK_SUCCESS );}
开发者ID:Ukusbobra,项目名称:open-watcom-v2,代码行数:53,
示例19: create_implib/* run dlltool on .def file to create import library */static voidcreate_implib (struct def_file *def, void *arg){ char *def_name; char *lib_name; char *p; int r; static char *argv[] = {NULL, "--as", NULL, "--output-lib", NULL, "--def", NULL, "--dllname", NULL, "-k", NULL}; fclose (def->f); def_name = xmalloc (strlen (def->dllname) + 5); lib_name = xmalloc (strlen (def->dllname) + 5); dll_to_def_name (def_name, def->dllname); p = strrchr (def->dllname, '.'); if (p) { *p = '/0'; sprintf (lib_name, "lib%s.a", def->dllname); *p = '.'; } else sprintf (lib_name, "lib%s.a", def->dllname); if (!keep_case) for (p = lib_name + 3; *p; p++) *p = tolower (*p); argv[0] = dlltool_program; argv[2] = as_program; argv[4] = lib_name; argv[6] = def_name; argv[8] = def->dllname; r = spawnvp (P_WAIT, argv[0], argv); if (r == -1) error (1, argv[0]); free (lib_name); free (def_name);}
开发者ID:Mocahteam,项目名称:SpringPP,代码行数:46,
示例20: wxExecute// wxExecute implementation//long wxExecute(wxChar **argv, int flags, wxProcess *process, const wxString* cwd, const wxEnvVariableHashMap* env){#if wxUSE_STREAMS const int STDIN = 0; const int STDOUT = 1; const int STDERR = 2; wxRedirectableFd in(STDIN), out(STDOUT), err(STDERR); bool redirect = process && process->IsRedirected() && (flags & wxEXEC_SYNC); if (redirect) { // close stdin/out/err and reopen them as files if (!in.Reopen(wxT("NUL"), O_RDONLY | O_TEXT)) return -1; if (!out.Reopen(wxFileName::CreateTempFileName(wxT("out")), O_CREAT | O_WRONLY | O_TRUNC | O_TEXT)) return -1; if (!err.Reopen(wxFileName::CreateTempFileName(wxT("err")), O_CREAT | O_WRONLY | O_TRUNC | O_TEXT)) return -1; }#endif // wxUSE_STREAMS // FIXME: suspend/resume gui int mode = flags & wxEXEC_SYNC ? P_WAIT : P_NOWAIT; int result = spawnvp(mode, argv[0], argv); if (result == -1) { wxLogSysError(_("can't execute '%s'"), argv[0]); }#if wxUSE_STREAMS if (redirect) process->SetPipeStreams(new wxTempFileInStream(out.Release()), new wxFFileOutputStream(wxT("NUL"), wxT("wt")), new wxTempFileInStream(err.Release()));#endif // wxUSE_STREAMS return result;}
开发者ID:yinglang,项目名称:newton-dynamics,代码行数:47,
示例21: sprintfvoid MissionLighting::dumpFileToVolumeAndRemove( const String& in_outVolName, const String& in_fileName ){ // Do the dump... // char volName[ 256 ]; sprintf( volName, "/"%s/"", in_outVolName.c_str() ); char fileName[ 256 ]; sprintf( fileName, "/"%s/"", in_fileName.c_str() ); char* argv[5]; argv[0] = "vt.exe"; argv[1] = "-sp"; argv[2] = const_cast<char*>(volName); argv[3] = const_cast<char*>(fileName); argv[4] = NULL; spawnvp(P_WAIT, "vt.exe", argv); DeleteFile(in_fileName.c_str());}
开发者ID:AltimorTASDK,项目名称:TribesRebirth,代码行数:20,
示例22: execute/*VARARGS1*/intexecute(char *a, ...) /* note: "exec" is already defined on u370 */{ va_list ap; int exitcode = -1; /* initialize, to avoid warning */ char *argv[BUFSIZ]; pid_t p; /* fork and exec the program or shell script */ endwin(); /* restore the terminal modes */ mousecleanup(); fflush(stdout); va_start(ap, a); for (p = 0; (argv[p] = va_arg(ap, char *)) != 0; p++) ;#if !HAVE_FORK /* HBB 20010313: in MSDOG, everything is completely different. * No fork()/exec()/wait(), but rather a single libc call: */ exitcode = spawnvp(P_WAIT, a, argv);#else if ((p = myfork()) == 0) { myexecvp(a, argv); /* child */ } else { exitcode = join(p); /* parent */ }#endif /* MSDOS */ /* the menu and scrollbar may be changed by the command executed */#if UNIXPC || !TERMINFO# ifndef __DJGPP__ /* leave CRLF handling as is */ nonl();# endif raw(); /* endwin() turns off cbreak mode so restore it */ noecho();#endif mousemenu(); drawscrollbar(topline, nextline); va_end(ap); return(exitcode);}
开发者ID:daisuke-3,项目名称:emacs-config,代码行数:42,
示例23: mainint main(int argc, char *argv[]){ int rc = -1; int index_cmd; index_cmd = mygetopt(argc, argv); if (optH) { usage(); return 0; } if (index_cmd >= argc || !logname) { fprintf(stderr, "Type 'TEECON -?' to help./n"); return 1; } if (optA) { rc = _dos_open(logname, O_RDWR, &tee_handle); if (rc == 0) my_doslseek(tee_handle, 0L, 2); else if (rc == 2) optO = 1; /* retry with creat when the file is not found */ else optO = 0; } if (optO && tee_handle == -1) rc = _dos_creat(logname, _A_NORMAL, &tee_handle); if (rc != 0) { fprintf(stderr, "FATAL: can't open the log file '%s'/n", logname); return -1; } my_psp = my_getpsp(); org_int21 = _dos_getvect(0x21); _dos_setvect(0x21, Int21Handler); if (argv[index_cmd]) { rc = spawnvp(P_WAIT, argv[index_cmd], (char const * const *)(argv + index_cmd)); } _dos_setvect(0x21, org_int21); fprintf(stderr, "%s : result=%d/n", argv[index_cmd], rc); if (tee_handle != -1) _dos_close(tee_handle); return rc;}
开发者ID:lpproj,项目名称:mydosuty,代码行数:40,
示例24: execute_commandint execute_command(cmd_data_t *cmd_data){ int target = 0; char *command; int a, total_len = 0; char *args[4]; for (a=0; a < cmd_data->num_args; a++) { if (cmd_data->arglist[a]) { total_len += strlen(cmd_data->arglist[a]) + 1; } } command = (char *)malloc( total_len ); command[0] = 0; for (a=0; a < cmd_data->num_args; a++) { if (cmd_data->arglist[a]) { strcat(command, cmd_data->arglist[a]); strcat(command, " "); } } command[strlen(command)-1] = 0; if (!silent) { puts(command); } cmd_data->num_args = target; cmd_data->arglist[cmd_data->num_args] = NULL; command = shell_esc(command); args[0] = SHELL_CMD; args[1] = "-c"; args[2] = command; args[3] = NULL; return spawnvp(P_WAIT, args[0], args);}
开发者ID:Ga-vin,项目名称:apache,代码行数:39,
示例25: do_aspawnintdo_aspawn ( void *vreally, void **vmark, void **vsp) { dTHX; SV *really = (SV*)vreally; SV **mark = (SV**)vmark; SV **sp = (SV**)vsp; char **argv; char *str; char *p2, **ptr; char *cmd; int rc; int index = 0; if (sp<=mark) return -1; ptr = argv =(char**) malloc ((sp-mark+3)*sizeof (char*)); while (++mark <= sp) { if (*mark && (str = SvPV_nolen(*mark))) argv[index] = str; else argv[index] = ""; } argv[index++] = 0; cmd = strdup((const char*)(really ? SvPV_nolen(really) : argv[0])); rc = spawnvp( P_WAIT, cmd, argv); free( argv); free( cmd); return rc;}
开发者ID:OPSF,项目名称:uClinux,代码行数:39,
示例26: RunCommandstatic int RunCommand( char *cmd ){ char *p; const char **argv; int i; bool skip_sp; skip_sp = true; i = 1; for( p = cmd; *p != '/0'; ++p ) { if( *p == ' ' ) { skip_sp = true; } else if( skip_sp ) { ++i; skip_sp = false; } } argv = (const char **)malloc( i * sizeof( char * ) ); if( argv == NULL ) return( 1 ); // error no memory skip_sp = true; i = 0; for( p = cmd; *p != '/0'; ++p ) { if( *p == ' ' ) { if( skip_sp ) continue; skip_sp = true; *p = '/0'; } else if( skip_sp ) { skip_sp = false; argv[i++] = p; } } argv[i] = NULL; i = (int)spawnvp( P_WAIT, cmd, argv ); free( (void *)argv ); return( i );}
开发者ID:Azarien,项目名称:open-watcom-v2,代码行数:38,
注:本文中的spawnvp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ special函数代码示例 C++ spawn_thread函数代码示例 |