Sponsored Content
Full Discussion: [C] exec system call
Top Forums Programming [C] exec system call Post 302581255 by lamachejo on Monday 12th of December 2011 01:23:05 PM
Old 12-12-2011
As always, I'm thankful for you answer Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

exec() system call

hi there, i was reading about the exec() function. and if i m not wrong, exec() kills your present process and starts a new process in its place. the process id remains the same. then it says if exec is successful the text data and stack are overlayed by new file! - i dont get this part "only... (2 Replies)
Discussion started by: a25khan
2 Replies

2. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

3. Programming

alternatives of exec() system function

Hi , Can anybody name any System Function in C/C++ for Sun-Solaris (unix) platform which can serve the alternative of execl() system function. Actually I am calling a fork-execl() pair and then making an interprocess communication between these two(parent-child process). But the problem is... (3 Replies)
Discussion started by: Raj Kumar Arora
3 Replies

4. UNIX for Advanced & Expert Users

exec to call specific function in C prog

I would like to call a particular function in a C program using execl(). Is this possible using execl or anyother function ? Thanks (2 Replies)
Discussion started by: vpraveen84
2 Replies

5. Shell Programming and Scripting

How to execute piped command using exec or system

Hi All, I want to execute a piped command like 'ls /opt | grep xml' using array as parameters list. How can I do that? (2 Replies)
Discussion started by: bharadiaam
2 Replies

6. Shell Programming and Scripting

system call

Hi, How to write a system calls in a script ? > cd $HOME > ls -ltr thanks in advance.. (10 Replies)
Discussion started by: hegdeshashi
10 Replies

7. Shell Programming and Scripting

Perl variables in exec or system

I am new in Perl. I am working in simple script and the varibles are working well outside the exec or system command. but they don't work as parameters to exec or system command. The script is attached. please help. (8 Replies)
Discussion started by: ahmed_zaher
8 Replies

8. UNIX for Dummies Questions & Answers

How to run two commands from a exec call in a c program

Hi, I have to run two commands one after another from a c program. How can i do this with exec system calls. i tried giving them as argument to execv but it is not working.please help thanks (3 Replies)
Discussion started by: suryashikha
3 Replies

9. Programming

system call

I have a cgi script which is called after certain time interval, which has this: system ("ls -l /tmp/cgic* | grep -v \"cgicsave.env\" | awk '{print $5}'"); During the execution of this script,the output is 0 sometimes. But due to this the system call is not working at all and doesnt o/p... (2 Replies)
Discussion started by: xs2punit
2 Replies

10. Programming

need help with system call

hi everyone i wrote a system call and compiled the kernel succesfully... my system call is in a file in the kernel folder named my_syscall1.c (kernel/my_syscall1.c) the header file for this system call i added it in the folder include like this include/my_syscall1/my_syscall1.h my problem is... (2 Replies)
Discussion started by: demis87
2 Replies
EXEC(2) 							System Calls Manual							   EXEC(2)

NAME
exec, execl, _clock - execute a file SYNOPSIS
#include <u.h> #include <libc.h> int exec(char *name, char* argv[]) int execl(char *name, ...) long *_clock; DESCRIPTION
Exec and execl overlay the calling process with the named file, then transfer to the entry point of the image of the file. Name points to the name of the file to be executed; it must not be a directory, and the permissions must allow the current user to execute it (see stat(2)). It should also be a valid binary image, as defined in the a.out(6) for the current machine architecture, or a shell script (see rc(1)). The first line of a shell script must begin with followed by the name of the program to interpret the file and any initial arguments to that program, for example #!/bin/rc ls | mc When a C program is executed, it is called as follows: void main(int argc, char *argv[]) Argv is a copy of the array of argument pointers passed to exec; that array must end in a null pointer, and argc is the number of elements before the null pointer. By convention, the first argument should be the name of the program to be executed. Execl is like exec except that argv will be an array of the parameters that follow name in the call. The last argument to execl must be a null pointer. For a file beginning #!, the arguments passed to the program (/bin/rc in the example above) will be the name of the file being executed, any arguments on the #! line, the name of the file again, and finally the second and subsequent arguments given to the original exec call. The result honors the two conventions of a program accepting as argument a file to be interpreted and argv[0] naming the file being exe- cuted. Most attributes of the calling process are carried into the result; in particular, files remain open across exec (except those opened with OCEXEC OR'd into the open mode; see open(2)); and the working directory and environment (see env(3)) remain the same. However, a newly exec'ed process has no notification handler (see notify(2)). When the new program begins, the global cell _clock is set to the address of a cell that keeps approximate time expended by the process at user level. The time is measured in milliseconds but is updated at a system-dependent lower rate. This clock is typically used by the profiler but is available to all programs. The above conventions apply to C programs; the raw system interface to the new image is as follows: the word pointed to by the stack pointer is argc; the words beyond that are the zeroth and subsequent elements of argv, followed by a terminating null pointer; and the return register (e.g. R0 on the 68020) contains the address of the clock. Alef In Alef, the intent and syntax are the same but the implementation is different. Exec (or execl; this description applies to either) may be called only by a proc holding a single task, typically the implicit main task of the proc. First, access(2) is called to see if the named file exists and has execute permission. If not, exec returns -1 immediately. Otherwise, it will never return: it frees resources private to the invoking proc and calls the exec system call. If this fails, it calls the bare _exits system call (see exits(2)) with the error string as argument. Therefore, if the file looks executable, the calling process is lost, whether the exec succeeds or not. SOURCE
/sys/src/libc/9syscall /sys/src/libc/port/execl.c SEE ALSO
intro(2), stat(2) DIAGNOSTICS
If these functions fail, they return and set errstr. There can be no return from a successful exec or execl; the calling image is lost. EXEC(2)
All times are GMT -4. The time now is 05:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy