Questions tagged [execv]

int execv(const char *path, char *const argv[]); Like all of the exec functions, execv replaces the calling process image with a new process image. This has the effect of running a new program with the process ID of the calling process. The command-line arguments are passed to the function as an array (Vector) of pointers.

The POSIX standard declares exec functions in the unistd.h header file, in C language. The same functions are declared in process.h for DOS and Microsoft Windows.

When execv() is successful, it doesn't return; otherwise, it returns -1 and sets errno.

185 questions
2
votes
2 answers

Working with C Arrays, Passing to execv()

I have a function: int exploreDIR (char stringDIR[], char arguments[6][100]) { /*stuff...*/ execv(filePath, arguments); } However, I get the warning: passing argument 2 of ‘execv’ from incompatible pointer type If execv expects…
Dan Brenner
  • 880
  • 10
  • 23
2
votes
1 answer

communicate with an execv()'ed program via pipe doesn't work

i try to write a socket which loads programs and redirects socket io to these. sounds much like inetd but as far as i know, inetd loads the program when its port is requested. i want to have it loaded permanently. so far so good. writing a socket…
TecDroiD
  • 113
  • 1
  • 6
2
votes
0 answers

execv() command hanging in C shell

I'm working on a C shell, and when I run /bin/ls it displays it properly, but hangs afterwords. The associated code I have is below, and I have a feeling it has to with a lack of a wait() statement in the parent case? for(p = j->first_process; p; p…
Parker
  • 8,539
  • 10
  • 69
  • 98
2
votes
6 answers

Using execv (C language) to run commands from a linux command prompt

The only part I am confused on thus far is how to set up execv with the first parameter as the current working directory. I've tried both "." and "~", neither are executing anything to the screen; same for "/." and "/~". I'm confused on how to have…
Baelix
  • 261
  • 2
  • 7
  • 17
1
vote
2 answers

How do I get the return value of a execv?

I am really new to C++ and I am trying to get the output from: execv("./rdesktop",NULL); I am programming in C++ and on RHEL 6. Like a FTP client, I would like to get all the status updates from my external running program. Can someone please tell…
TheBigOnion
  • 615
  • 3
  • 9
  • 19
1
vote
0 answers

python 2.4 execv hangs the process on AIX 5.1

I am trying to fork a process using python 2.4 on AIX 5.1 , I am using the following code def runcmd(cmd): (pid, fd) = pty.fork() argv = cmd.split() if not pid: print "In child process" #time.sleep(1) …
Mircea
  • 393
  • 1
  • 4
  • 11
1
vote
1 answer

ANSI C - Execute Process, Wait, Delete File

I am trying to execute LP to print a PDF document and wait for it to exit. After it exists i am trying to delete the file with unlink(); However the wait finishes even before execv execute LP. I am not quite sure how to handle this and why the wait…
oipoistar
  • 477
  • 6
  • 19
1
vote
1 answer

How to have a script open another script in a way that interacts well with other features of a JetBrains-IDE?

I have a script that is basically just a small GUI to create a config-file for a long-running-program without any graphics. I have and control the source-code for both of these. The usual workflow of the developer-users is to open that GUI using a…
julaine
  • 382
  • 3
  • 12
1
vote
0 answers

Getting result of exec*() from child process without waiting in any case (not using pipes and vfork())

I am working on custom wrappers for Unix-specific system calls now. And the last problem I met is about how to create a complete function for creating new processes with another image. And I want this function to return TRUE or FALSE. The last piece…
1
vote
1 answer

C++ fork and threads, mysql and execv

I'm afraid I have to take out a bit of length so that my question can be understood exactly. I know that forking can cause some problems, especially if you mix it with threads. One nasty problem I encountered was that a thread was cloned by a fork…
SoulfreezerXP
  • 459
  • 1
  • 5
  • 19
1
vote
1 answer

How do I tar compress without parent and root files in one line for execv()

This question's been asked a million times on this site with various different solutions, but non of them seems to work for my case. So far the most promising one is tar -cvf testetest.tar -C folder1 * where folder1 includes: Folder1 >txt1.txt …
Sheng
  • 75
  • 7
1
vote
3 answers

Having trouble running 2 child processes

In this program, mulproc.c , I am trying to run the executables from two programs I made (one counts the amount of alphabetic characters in a file and the other one counts five specific special characters). I am trying to make a parent process…
PluffTed
  • 53
  • 5
1
vote
1 answer

How to get information about spawned children from their PID

In my program I am spawning child processes by using fork and execv. I am saving the child PIDs in an array. How can I get information about the children by using these PIDs? I want to get information like how much memory and CPU they are using.
node ninja
  • 31,796
  • 59
  • 166
  • 254
1
vote
2 answers

How to read the return code from a child process

I use fork and execv to execute a child process. In the parent program, I have this: int status; wait(&status); cout << "return code = " << status << endl; Will that wait for the child process to terminate and then display it's return code?
node ninja
  • 31,796
  • 59
  • 166
  • 254
1
vote
5 answers

How to get the pid of a program started with fork and execv

In this program, I start another process with execv. if (fork() == 0) { struct rlimit limits; limits.rlim_cur = 10000000; // set data segment limit to 10MB limits.rlim_max = 10000000; // make sure the child can't increase it again …
node ninja
  • 31,796
  • 59
  • 166
  • 254
1 2
3
12 13