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

using execv instead of execl in linux

I wrote a program to use execl and I want to have the same functionality but instead use execv. here is my program from execl: #include #include int main (int argc, char *argv[]) { int pid, status,waitPid, childPid; …
Lain
  • 2,166
  • 4
  • 23
  • 47
-1
votes
1 answer

How to use execl in order to pipe multiple processes

I am still new to OS domnain. Currently i am trying to implement a shell in C, one of the main feature being the ability to pipe. My question is: After executing the fork dup and other needed processes how should i write inside the execl in case i…
-1
votes
1 answer

Use of execl (Arguments)

New to C. So I have a program called test.c (doesnt need any arguments to start, compiled like this " gcc test.c -o test") I want to make my other program execute test I know I have to use execl but I just cant understand the arguments in the…
Ventura
  • 97
  • 12
-1
votes
3 answers

execl in C programming

I have a C program. I noticed that you can't put 2 execl's in it. The code: #include #include #include #include #include int main() { pid_t fork(void); int system(const char…
Ivan
  • 3
  • 2
-1
votes
1 answer

execl command in c under Linux ubuntu

I want to call an executable from a C application . Here is my code: execl("/home/ion/workspace/DNS/Debug","DNS","216.58.198.164","A",(char*)NULL); where IP and "A" are supposed to be argv[1] and argv[2] This application called DNS is supposed to…
joesid
  • 671
  • 1
  • 10
  • 21
-1
votes
1 answer

How compiler a program which include math.h library with execl()

execl("/usr/bin/cc","cc","myprog.c",NULL) I use the this line for compiler to myprog.c in myMainProg. But myprog.c have #include "math.h" . So I have to add -lm. How can I do that?
o_O
  • 51
  • 7
-1
votes
2 answers

How to send continuous stream of data from one process to another via EXECL

I am writing C program which constantly generates two string values named stateName and timer (with the rate of five times per second). I need to concatenate and pass them to another process called ProcessNo3_TEST which is responsible for tokenizing…
Bababarghi
  • 571
  • 1
  • 4
  • 23
-1
votes
1 answer

execl() works on one of my code, but doesn't work on another

I already used execl() in code, and it worked well. But this time, I really have no idea why it doesn't work. So here's the code that do not work #include #include int main() { int i = 896; printf("please\n"); …
shklaurant
  • 45
  • 6
-1
votes
1 answer

why execl overwrite the file

#include #include #include #include #include // open #include int main() { close(1); // close standard out open("log.txt", O_RDWR | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); …
kww
  • 1
  • 3
-3
votes
1 answer

Problem with getting integer value from atoi()

I am trying to write a simple program which passes the PID of the parent process to the child process and print, however when I use the atoi() function I am not receiving the correct parent PID value. I'm not sure what I am doing wrong. I have read…
Dan
  • 11
  • 2
-3
votes
1 answer

What does execl ("/bin/emacs", "/etc/fstab"); do?

for example: int pid1 = fork(); printf("%s\n", "[1]"); int pid2 = fork(); printf("%s\n", "[2]"); if ((pid1 == 0) && (pid2 == 0)) { printf("%s\n", "[3]"); execl("/bin/emacs", "/etc/fstab"); int pid3 = fork(); printf("%s\n", "[4]"); }…
Basler182
  • 7
  • 3
-4
votes
2 answers

Can't use execl in C

I am trying to execute this execl command in a C program and it simply doesn't work. execl("~/Desktop/taskc/validating/analyzer/numbers_analyzer", "numbers_analyzer", (char*)NULL); bash: syntax error near unexpected token…
Miguel
  • 1
  • 5
-5
votes
2 answers

getting trouble with running program in c on linux

why I am not succeed int main(char* name,int arg0,int arg1) { name = "/u/e2014/Desktop/os/Prog.c"; arg0 = 0; arg1 = 1; char my_args[3]; my_args[0] = arg0; my_args[1] = arg1; my_args[2] = NULL; execl(name,m_args); …
LIMA
  • 125
  • 1
  • 1
  • 8
-6
votes
1 answer

Creating child process in C linux

Create child process by using fork() function. The parent process runs change content of the process by execl() function which run cat f1.c command. child process runs a traceroute www.google.com command.
1 2 3 4 5 6 7
8