⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 execvp.c

📁 标准c库代码,可以应用于各个系统提供了大量的基本函数
💻 C
字号:
/* execvp.c *//* This and the other exec*.c files in this directory require    the target to provide the execve syscall.  */#include <_ansi.h>#include <stdlib.h>#include <unistd.h>#include <errno.h>/* * Copy string, until c or <nul> is encountered. * NUL-terminate the destination string (s1). */static char *_DEFUN (strccpy, (s1, s2, c),	char *s1 _AND	char *s2 _AND	char c){  char *dest = s1;  while (*s2 && *s2 != c)    *s1++ = *s2++;  *s1 = 0;  return dest;}int_DEFUN (execvp, (file, argv),	_CONST char *file _AND	char * _CONST argv[]){  char *path = getenv ("PATH");  char buf[MAXNAMLEN];  if (file[0] == '/')  /* pathname -- easy out */    return execv (file, argv);  buf[0] = 0;          /* lots of initialization here 8-) */  while (*path)    {      strccpy (buf, path, ':');      strcat (buf, "/");      strcat (buf, file);      execv (buf, argv);      if (errno != ENOENT)	return -1;      while (*path && *path != ':')	path++;    }    return -1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -