06-02-2008
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
10 More Discussions You Might Find Interesting
1. Programming
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. Shell Programming and Scripting
Hi,
I wrote a smiple ksh function
send_notification() {
...
}
and want to execute it on each file, matched by the find command.
I tried:
find / -name "*.err" -mtime -8 -exec send_notification {} \;
but it doesn't work. What should I do? I work in ksh on Hp-Ux.
Regards,
Pit (11 Replies)
Discussion started by: piooooter
11 Replies
3. Shell Programming and Scripting
Dear Friends,
I want to know how to call a Linux commands in C programs. (1 Reply)
Discussion started by: krishna_sicsr
1 Replies
4. Programming
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
5. Programming
Runtime.getSystem.exec() waits for child process to complete .. I do not want to wait for the child process to complete ..what is the option which has to be used ? (2 Replies)
Discussion started by: shafi2all
2 Replies
6. Shell Programming and Scripting
I have a java program to validate a XML file. I want to call this java program in a shell script which will be registered as concurrent program in oracle apps.
Can anyone please let me know the step by step appraoch required to call java program in shell script like ....intial steps... (1 Reply)
Discussion started by: kcp_pavan
1 Replies
7. Infrastructure Monitoring
Hello,
I have a problem with package and name space.
require "/Mehran/DSGateEngineLib/general.pl";
use strict;
sub System_Status_Main_Service_Status_Intrusion_Prevention
{
my %idpstatus;
my @result;
&General_ReadHash("/var/dsg/idp/settings",\%idpstatus);
#print... (4 Replies)
Discussion started by: Zaxon
4 Replies
8. UNIX for Dummies Questions & Answers
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. Shell Programming and Scripting
Below is my script that is function properly per my conditions but I am facing one problem here that is when one function fails then Iy should not check other functions but it calls the other function too So anyone can help me how could i achieve this?
iNOUT i AM GIVING TO THE... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies
10. Programming
Hi again ;) Now I want to make a program that will execute the programs with exec, asking the user if he wants the program to run in background or foreground.
scanf("%c",&caracter);
if (caracter=='y'){
printf("Has decidido ejecutarlo en background\n");
if((pid=fork())==0) {// fork para... (3 Replies)
Discussion started by: lamachejo
3 Replies
stdarg(3) Library Functions Manual stdarg(3)
NAME
stdarg - Handles a variable-length parameter list
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <stdarg.h>
va_list void va_start ( va_list argp, parmN ); type va_arg ( va_list argp, type ); void va_end ( va_list argp );
PARAMETERS
argp Specifies a variable that the stdarg macros use to keep track of the current location in the parameter list. Do not modify this
variable.
parmN Specifies the last named parameter (the one just before the
"..." in the execl() definition in the Example section). There must be at least one named parameter.
type Specifies the type to which the expected argument will be converted when passed as an argument. Unsigned char or short arguments
are converted to unsigned int, and float arguments are converted to double. Different types can be mixed, but it is up to the rou-
tine to know what type of argument is expected because the type cannot be determined at run time.
DESCRIPTION
The stdarg set of macros allows you to write portable functions that accept a variable number of parameters. Subroutines that have vari-
able-length parameter lists (such as the printf() function), but that do not use the stdarg macros, are inherently nonportable because dif-
ferent systems use different parameter-passing conventions.
The stdarg macros are as follows:
va_list
Defines the type of the variable used to traverse the list.
va_start()
Initializes argp to point to the first unnamed argument. The va_start() macro will be invoked before any access to the unnamed
arguments.
va_arg()
Returns the next parameter in the list pointed to by argp.
va_end()
Cleans up at the end.
Your function can traverse, or scan, the parameter list more than once. Start each traversal with a call to va_start() and end it with
va_end().
EXAMPLE
The following example is a possible implementation of the execl() function: #include <stdarg.h> #define MAXargS 100 /* ** execl is called
by ** execl(file, arg1, arg2, . . . , (char *) 0); */ execl(char * file, . . .) { va_list ap;
char *file;
char *args[MAXargS];
int argno = 0;
va_start(ap, file);
while ((args[argno++] = va_arg(ap, char *)) != (char *) 0)
; /* Empty loop body */
va_end(ap);
return (execv(file, args)); }
NOTES
The calling routine is responsible for specifying the number of parameters because it is not always possible to determine this from the
stack frame. For example, the execl() function is passed a null pointer to signal the end of the list. The printf() function determines the
number of parameters from its fmt parameter.
AES Support Level: Temporary use
RELATED INFORMATION
Functions: exec(2), printf(3), varargs(3), vprintf(3) delim off
stdarg(3)