Sponsored Content
Full Discussion: time execl
Top Forums Programming time execl Post 302286527 by jim mcnamara on Wednesday 11th of February 2009 11:09:09 AM
Old 02-11-2009
I am assuming you wait() in the parent until the execl() command finishes.
this is what struct rusage looks like on hpux - your system may have it set up differently
Code:
 int getrusage(int who, struct rusage *r_usage);

struct  rusage {
        struct timeval ru_utime;        /* user time used */
        struct timeval ru_stime;        /* system time used */
                                        /* actual values kept in proc struct */
        long    ru_maxrss;
#define ru_first        ru_ixrss
        long    ru_ixrss;               /* integral shared memory size */
        long    ru_idrss;               /* integral unshared data " */
        long    ru_isrss;               /* integral unshared stack " */
        long    ru_minflt;              /* page reclaims */
        long    ru_majflt;              /* page faults */
        long    ru_nswap;               /* swaps */
        long    ru_inblock;             /* block input operations */
        long    ru_oublock;             /* block output operations */
        long    ru_ioch;                /* # of characters read/written */
        long    ru_msgsnd;              /* messages sent */
        long    ru_msgrcv;              /* messages received */
        long    ru_nsignals;            /* signals received */
        long    ru_nvcsw;               /* voluntary context switches */
        long    ru_nivcsw;              /* involuntary " */
#define ru_last         ru_nivcsw
};

The two embedded structures ru_utime and ru_stime have time values for user mode and system mode cpu use, respectively.

The RUSAGE_CHILDREN "who" flag returns the usage in child processes - this case the execl() call.
 

10 More Discussions You Might Find Interesting

1. Programming

execl, execv or execp

Hi! I'm writing a C program which gets from the command line a shell command (such as "ls" ) and I should execute it. My Q is: how can I send a command to the shell? I know I have to use one of the above functions, but I don't know how to use them. Thanks eyal (1 Reply)
Discussion started by: azran
1 Replies

2. Programming

execl / execv ?

Hi, Is it possible to run a program from my C program using only the full pathname? for example if I wanna call: "ls", so I whould have to use: execl("/bin/ls", "ls", NULL); Is it possible to do this using only: "/bin/ls" thanks (1 Reply)
Discussion started by: owijust
1 Replies

3. Programming

How to specify path of a function within execl

Consider the following scenario program1: main() { ...... execl("path","function",...); ..... } function() { ----- ------- } Now i want to include the path of function in execl. How to do this. should the path be the path of function's executable file. If it so how... (1 Reply)
Discussion started by: bankpro
1 Replies

4. Programming

execl()

can anyone explain how to pass arguments of a program in execl function pls explain with a sample code. (2 Replies)
Discussion started by: bankpro
2 Replies

5. Shell Programming and Scripting

need help with execl command

I want to make simultanous sh commands in an exec command for example I want to counts the lines in a file wc -l my file.txt | awk -F" " '{print $1}'` works fine in sh but I want to implement it in a c code the first part works like this execl("/usr/bin/wc", "wc", "-l", "myfile.txt",... (1 Reply)
Discussion started by: walnut
1 Replies

6. Programming

execl function at GDB

Hi, we would appreciate if any one answer the below query. void main() { printf(“ I am in main\n”); execl(“/HOME/source/file2”,” /HOME/source/file2”,1,0); printf(“after execl\n”); } How to step the file2 source code in GDB. (2 Replies)
Discussion started by: RAMESHPRABUDASS
2 Replies

7. Red Hat

execl command

how to use find command in execl function, I used: execl("/usr/bin/find","find","~","-name","filename.c",0); but it shows find: ~ no file and directory i need to get the path of the file from the home .:wall: (2 Replies)
Discussion started by: Mahendravarma
2 Replies

8. Programming

When execl fails in C

when execl fails using the command lss, it doesnt go into the next line execl("/bin/sh", "/bin/sh", "-c", command, NULL); perror("execl failed"); exit(127); for some reason the child process just stops and also the parent process also stops so the line after the line that... (3 Replies)
Discussion started by: omega666
3 Replies

9. Programming

[C] execl and pipes?

Hi, I have two programs, one is named "Master" and the other one "slave". What I want to do is , when I execute Master, inside slave will be called by excecl, do some calculations, and send those to the master program... A little example of what I am failing to do: if ((PID1=fork())==0) { //... (6 Replies)
Discussion started by: lamachejo
6 Replies

10. UNIX for Beginners Questions & Answers

Execl() command

Hi, If I write in a c file : execlp("date","date",NULL); printf("A\n"); And then run through the terminal would "A" be printed ? I understood that execlp will exit the program after it finished so the next lines of code won`t be executed afterwards.. Is that true ? (1 Reply)
Discussion started by: uniran
1 Replies
GETRUSAGE(2)						     Linux Programmer's Manual						      GETRUSAGE(2)

NAME
getrusage - get resource usage SYNOPSIS
#include <sys/time.h> #include <sys/resource.h> int getrusage(int who, struct rusage *usage); DESCRIPTION
getrusage() returns resource usage measures for who, which can be one of the following: RUSAGE_SELF Return resource usage statistics for the calling process, which is the sum of resources used by all threads in the process. RUSAGE_CHILDREN Return resource usage statistics for all children of the calling process that have terminated and been waited for. These statistics will include the resources used by grandchildren, and further removed descendants, if all of the intervening descendants waited on their terminated children. RUSAGE_THREAD (since Linux 2.6.26) Return resource usage statistics for the calling thread. The resource usages are returned in the structure pointed to by usage, which has the following form: struct rusage { struct timeval ru_utime; /* user CPU time used */ struct timeval ru_stime; /* system CPU time used */ long ru_maxrss; /* maximum resident set size */ long ru_ixrss; /* integral shared memory size */ long ru_idrss; /* integral unshared data size */ long ru_isrss; /* integral unshared stack size */ long ru_minflt; /* page reclaims (soft page faults) */ long ru_majflt; /* page faults (hard page faults) */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* IPC messages sent */ long ru_msgrcv; /* IPC messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary context switches */ }; Not all fields are completed; unmaintained fields are set to zero by the kernel. (The unmaintained fields are provided for compatibility with other systems, and because they may one day be supported on Linux.) The fields are interpreted as follows: ru_utime This is the total amount of time spent executing in user mode, expressed in a timeval structure (seconds plus microseconds). ru_stime This is the total amount of time spent executing in kernel mode, expressed in a timeval structure (seconds plus microseconds). ru_maxrss (since Linux 2.6.32) This is the maximum resident set size used (in kilobytes). For RUSAGE_CHILDREN, this is the resident set size of the largest child, not the maximum resident set size of the process tree. ru_ixrss (unmaintained) This field is currently unused on Linux. ru_idrss (unmaintained) This field is currently unused on Linux. ru_isrss (unmaintained) This field is currently unused on Linux. ru_minflt The number of page faults serviced without any I/O activity; here I/O activity is avoided by "reclaiming" a page frame from the list of pages awaiting reallocation. ru_majflt The number of page faults serviced that required I/O activity. ru_nswap (unmaintained) This field is currently unused on Linux. ru_inblock (since Linux 2.6.22) The number of times the file system had to perform input. ru_oublock (since Linux 2.6.22) The number of times the file system had to perform output. ru_msgsnd (unmaintained) This field is currently unused on Linux. ru_msgrcv (unmaintained) This field is currently unused on Linux. ru_nsignals (unmaintained) This field is currently unused on Linux. ru_nvcsw (since Linux 2.6) The number of times a context switch resulted due to a process voluntarily giving up the processor before its time slice was com- pleted (usually to await availability of a resource). ru_nivcsw (since Linux 2.6) The number of times a context switch resulted due to a higher priority process becoming runnable or because the current process exceeded its time slice. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EFAULT usage points outside the accessible address space. EINVAL who is invalid. CONFORMING TO
SVr4, 4.3BSD. POSIX.1-2001 specifies getrusage(), but specifies only the fields ru_utime and ru_stime. RUSAGE_THREAD is Linux-specific. NOTES
Resource usage metrics are preserved across an execve(2). Including <sys/time.h> is not required these days, but increases portability. (Indeed, struct timeval is defined in <sys/time.h>.) In Linux kernel versions before 2.6.9, if the disposition of SIGCHLD is set to SIG_IGN then the resource usages of child processes are automatically included in the value returned by RUSAGE_CHILDREN, although POSIX.1-2001 explicitly prohibits this. This nonconformance is rectified in Linux 2.6.9 and later. The structure definition shown at the start of this page was taken from 4.3BSD Reno. Ancient systems provided a vtimes() function with a similar purpose to getrusage(). For backward compatibility, glibc also provides vtimes(). All new applications should be written using getrusage(). See also the description of /proc/PID/stat in proc(5). SEE ALSO
clock_gettime(2), getrlimit(2), times(2), wait(2), wait4(2), clock(3) COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2010-09-26 GETRUSAGE(2)
All times are GMT -4. The time now is 02:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy