execv

unix path searching C function

Hi, I am programming a UNIX shell and I have to use the execv() system call to create a process. One of the parameters for execv() is the filepath for the executable. So if somebody types in /bin/ls, it will run the ls executable. But what I need is a function that when ls is typed, it will search for the filepath of ls (like the "whi...

How to wait for a child that respawns itself with os.execv() on win32?

Hi all I have some code that uses pip to bootstrap a Python envionment for out build process: this is a lovely way of ensuring we get proper isolation of the build requirements from the rest of the host system, and helping us get more consistent build results overall. Anyway, the code I have that drives pip.py appears to have some prob...

Illegal Argument Execv() Unix C++

So I basically have a vector args with 1 argument per array that I'm trying to pass to an execv() call in unix. Execv accepts two parameters like so: int execv(const char *path, char *const argv[]); What's the best way to convert my vector of strings to an array of pointers ? Right now I'm doing the following but when I run it with s...

C++ fork() and execv() problems

Hi all, I am kind of newbie on C++, and working on a simple program on Linux which is supposed to invoke another program in the same directory and get the output of the invoked program without showing output of the invoked program on console. This is the code snippet that I am working on: pid_t pid; cout<<"General sentance:"<<en...

Pipe is not receiving all output from child process

I wanted to open up a pipe to a program and read output from it. My initial inclination was to use popen(), but the program takes a number of options, and rather that fighting with shell quoting/escaping, I decided to use a combination of pipe(), fork(), dup() to tie the ends of the pipe to stdin/stdout in the parent/child, and execv() t...

Executing a command from C++, What is expected in argv[0]?

I am using execv() to run commands from /bin/ such as 'ls', 'pwd', 'echo' from my c++ program, and I am wondering what value I should provide in argv[0]; const char * path = getPath(); char ** argv = getArgs(); execv(path,argv); ...

A question about execv and process family relationship

After a process forks and the forked son invokes execv, is the result still the son of the father? ...

Would this be considered a memory leak?

Consider this pointless program: /* main.c */ #include <stdlib.h> #include <unistd.h> int main(int argc, char **argv) { int i; for (i = 0; i < 1024; i++) { int pid = fork(); int status; if (pid) { wait(&status); } else { char *ptr = (char *)malloc(1024*sizeof(char...

why might execv crash?

#include <stdio.h> #include <unistd.h> #include <stdlib.h> int main (int argc, const char * argv[]) { printf("start\n"); char *const parmList[] = {"/bin/ls", "-l", NULL}; execv("/bin/ls", parmList); return 0; } I compiled with GCC4.2 Any ideas why this might crash? I'm not getting any error messages in xcode. EDIT: us...

Cross-platform way to specify Python interpreter when running with execv

I am currently running a Python scripts both on Linux and Windows 7. The file is executed in an execv style with which I mean that the interpreter is defined in the beginning of the file in a command. In Windows system, the interpreter specification is: #!C:\Python26\python.exe However in Linux this needs to be #!/usr/bin/python I...