Questions tagged [execl]

execl() is a C library function which is used to replace the current process image with a new process image. It belongs to the family of exec() functions and prototyped in unistd.h.

execl() is a C library function which is used to replace the current process image with a new process image. It belongs to the familt of exec() functions and prototyped in unistd.h.

The Function Prototype

int execl(const char *path, const char *arg, ...);

where,

  • The first argument is the name of a file that is to be executed.
  • The const char *arg and subsequent arguments (if any) can be thought of as arg0, arg1, ..., argn. Together they describe a list of one or more pointers to null-terminated strings that represent the argument list available to the executed program.

Return Value

The various exec() functions only return if an error has occurred. The return value is -1, and errno is set to indicate the error.

Check the Main page for more details.

120 questions
0
votes
1 answer

Pass parameter to another function using C

int main(void){ int n, user_length; char userid[30]; char password[11]; if ((n = read(STDIN_FILENO, userid, 10)) == -1) { perror("read"); exit(1); } else if(n == 0) { fprintf(stderr, "Error: could not read from stdin"); …
0
votes
1 answer

exec segfault of trivial C program

Running a trivial program within gdb, that forks and execl a client. The execl line (while inside inferior 2 in gdb) gives the process ID "is executing new program" and then immediately seg faults. Code to that point follows: int main(int argc,…
Aenid37
  • 16
  • 2
0
votes
1 answer

How to use execl as replacement for system

int main(void) { execl("echo", "test"); return 0; } I want to execute command echo test with execl Why ? Because i can't use system() i have some reasons What is wrong ?
Starrrks_2
  • 115
  • 1
  • 8
0
votes
1 answer

print to screen from fifo stdout failed

I have a program which has 2 children (running 2 processes by execl), and one fifo. I can't use printf, and I want both children to write and read from fifo. problem is, I want only first child to make sure that everything he writes to my FIFO will…
Zohar Argov
  • 143
  • 1
  • 1
  • 11
0
votes
1 answer

How to copy files to folder with execlp?

I need to copy a file (the name of the file is entered via the keyboard) inside a folder (called backup) using execpl printf("File name to copy? "); scanf(" %99[^\n]", str); char *args[] = { "cp", str,"/backup" }; p = fork(); // Fork validations…
Mark
  • 77
  • 1
  • 3
  • 10
0
votes
2 answers

How to correctly kill a program which is started using execl

I wrote a program which creates a child process using fork. In the child process I use execl which opens a local html page using firefox: execl( "/usr/bin/firefox", "/usr/bin/firefox","/home/xyz/t/webpages/page1.html", (char*)NULL); In the parent…
nagla
  • 87
  • 1
  • 9
0
votes
1 answer

Execl Permission Denied

Creating a producer/consumer system. The producer is meant to call the consumer but i am getting the error execl failed for producer: Permission denied Here is the call: if (execl("/home/aaron/Documents/Programming/c/producerAsignment", …
Aaron Nebbs
  • 506
  • 1
  • 6
  • 15
0
votes
1 answer

Redirection doesn't work - the output of the client seems just an empty string

I'm trying to redirect to a socket the output of another program, I've tried with dup2 (STDOUT_FILE, socketfd); execl("/bin/ls","ls",(char*)0) in the Server's source code, and the read (socketfd,buff,1) in the Client source code.. But the output of…
Luigi Blu
  • 129
  • 13
0
votes
2 answers

How to execute a program in C++ Linux

I have a cpp project, which executes another program. Here is my test: int main() { execl("java -jar /pathOfJAR/myjar.jar", NULL); return 0; } I ran this project and I got nothing. Then I tried like this: execl("java", "-jar",…
Yves
  • 11,597
  • 17
  • 83
  • 180
0
votes
1 answer

How to know if an SSH connection failed?

I have to run a ssh command in a separate process (so by means of execlp) to connect the running machine to another machine in the same local network. The thing is, I have to establish the hostname entered is valid so the ssh connection…
WIlopu
  • 47
  • 7
0
votes
2 answers

measuring number of execl

I want to measure the number of execl call per second, but my script terminates after first iteration because execl has a leave function built in! I want to know how I can return to my script or find a way to count: t_end = time.time() + 60 counter…
0
votes
1 answer

Trouble with Pointers and child processes in C

Everytime this code is run, 0's and a null are passed in as the arguments for my child process. I know its something to do with pointers, but I cant seem to populate my array and pass the arguments along. I've looked at it too long and I'm hoping…
0
votes
1 answer

Using grep with execl()

A little context for my project: We have an arbitrary number of files that need a separate process for each file then need to search using an exec() call to find every time a specific KEY is used. I know how to use grep from the command line using…
Alex
  • 9
  • 4
0
votes
1 answer

execl in child process works for only in specific cases

I have been bussy for the last five hours with this problem so I hope someone can help me out. In my C++ program (which I develop in QTcreator on lubuntu) I want to run airodump-ng in the child process of my program. The output of airodump-ng should…
Rik Smits
  • 63
  • 9
0
votes
2 answers

Calling an executable file with execlp()

I'm trying to compile 2 executable files. One of them is sampler and other one is collector. Sampler must be called from a child of collector. Sampler one writes some datas to shared memory and collector should read it from shared memory. I am using…
gizux
  • 13
  • 2