ENOENT error occurs while issueing execlp command

Thread Tools Search this Thread
Operating Systems HP-UX ENOENT error occurs while issueing execlp command
# 1  
Old 08-10-2009
ENOENT error occurs while issueing execlp command


* TEST NAME: setrlimitd_su.c
* PURPOSE: To verify the soft (rlim_cur) and hard (rlim_max) limit
* of process RLIMIT_DATA resources correctly inherited by
* the exec() system call.
* RESULT: function call should pass (exit 0) otherwise exit with
* EWRONGLIM for incorrect limit (check d.txt for errors).
* COMMENTS: Test setup is similarly to the original setrlimit_su.c.
* The algorithm is formulated based upon the defects found
* by the VSU standard tests. It exec'es ./dlim prog file.
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/mman.h>
#include <inttypes.h>
#include "defs.h"
void func(id_t, rlim_t, rlim_t, rlim_t, rlim_t);
char cur_arg[NUM_CHBUFS];
char max_arg[NUM_CHBUFS];
struct rlimit dlim; 
rlim_t org_dcur, org_dmax, dcur, dmax;
if (getuid()) {
fprintf(stderr, "ERROR: test must be run as root\n");
getrlimit(RLIMIT_DATA, &dlim);
org_dcur = dlim.rlim_cur;
org_dmax = dlim.rlim_max;
/* Decrement limits by 1. */
dcur = org_dcur-1;
dmax = org_dmax-1;
printf("Original RLIMIT_DATA values:\n");
printf("dlim.rlim_cur = 0x%lx\n", org_dcur);
printf("dlim.rlim_max = 0x%lx\n", org_dmax);
printf("\nTest: Lower cur, max RLIMIT_DATA by 1, then call exec\n");
/* (cur,max) (cur,max) */
/* uid, init limits, new limits */
func( 1, org_dcur, org_dmax, dcur, dmax);
func( id_t id, /* The uid to use when running this test (0/non-0) */
rlim_t org_cur, /* The values at the beginning of the test */
rlim_t org_max,
rlim_t cur, /* The values to set */
rlim_t max
pid_t child, g_child;
int status;
int rv;
struct rlimit lim, ret_lim;
int i;
int ret=0;
ret=execlp("dlim", "dlim",ultostr(cur,16), ultostr(max,16), NULL);
printf("return valu is %d\n",ret);
* Set up a child to do all the work because the child has to 
* change uids
if ((child= fork()) == (pid_t)-1) {
perror("ERROR: fork");
printf("errno = %d\n", errno);
else if (child) { /*parent*/
waitpid(child, &status, 0);
if (WEXITSTATUS(status)) /* If test failed */
if (WIFSIGNALED(status)) /* If test died from signal */
raise(WTERMSIG(status)); /*We should get it too */
else { /*child, which does all the work */
lim.rlim_cur = org_cur;
lim.rlim_max = org_max;
printf("| Begin test with RLIMIT_DATA |\n");
printf("Setting original setrlimit ");
printf("org_cur=0x%lx org_max=0x%lx\n", org_cur, org_max);
if (setrlimit(RLIMIT_DATA, &lim)== -1) {
perror("ERROR: 1st setrlimit, RLIMIT_DATA");
printf("errno = %d\n", errno);

if ( (id) && (setuid(id) == -1) ) {
perror("ERROR: setuid failed");
printf("errno = %d\n", errno);
printf("Setting new lowered setrlimit ");
printf("cur=0x%lx max=0x%lx\n", cur, max);
lim.rlim_cur = cur;
lim.rlim_max = max;
rv = setrlimit(RLIMIT_DATA, &lim);
if (rv != 0) {
perror("ERROR: Unexpected failure");
printf("errno = %d\n", errno);

*Now we make sure the call did the right thing 
if (getrlimit(RLIMIT_DATA, &ret_lim) == -1) {
perror("ERROR: getrlimit failed");
printf("errno = %d\n", errno);
printf("After new setrlimit, getrlimit returned ");
printf("cur=0x%lx max=0x%lx\n", ret_lim.rlim_cur, ret_lim.rlim_max);
if ((ret_lim.rlim_cur != cur) || (ret_lim.rlim_max != max)) { 

perror("ERROR: wrong limits returned by getrlimit\n");
printf("errno = %d\n", errno);
* We decrement the original cur and max of RLIMIT_DATA 
* by one and try to exec ./dlim executable file to verify 
* if the lowered limits are retained across the execlp() call.
printf("Calling exec to test for setrlimit of RLIMIT_DATA\n");
printf("cur=0x%lx max=0x%lx)\n", cur, max);

printf("Now, execlp(\"./dlim\")\n");
printf("printing... execlp(\"./dlim\")\n");
printf(" %s, %s\n", ultostr(cur,16), ultostr(max,16));
* Set up a grandchild to perform the exec call.
if ((g_child=fork()) == (pid_t)-1) {
perror("ERROR: fork");
else if (g_child) { /*parent*/
waitpid(g_child, &status, 0);
if (WEXITSTATUS(status)) { /* If test failed */
fprintf(stderr, "ERROR: exec'ed wrong limits -- please check d.txt\n");
else if (WEXITSTATUS(status)==EWRONGARG)
fprintf(stderr, "ERROR: incorrect number of args passed into exec'ed prog.\n");
fprintf(stderr, "ERROR: after exec'ed\n"); 
if (WIFSIGNALED(status)) /* If test died from signal */
raise(WTERMSIG(status)); /*parent gets it too */
else { /* g_child will do the exec and NOT return */
rv = execlp("dlim", "dlim", 
ultostr(cur,16), ultostr(max,16), NULL); 
if (rv == -1) {
perror("ERROR: execlp(./dlim) failed");
printf("errno = %d\n", errno);
else {
perror("ERROR: shouldn't be returned here from the exec() call!");
printf("errno = %d\n", errno);


I am getting error at execlp command.Error is ENOENT.For understanding the codeflow copied entire code.

Below is the output for the above code..

Test: Lower cur, max RLIMIT_DATA by 1, then call exec
return valu is -1
| Begin test with RLIMIT_DATA |
Setting original setrlimit org_cur=0x100000000 org_max=0x100000000
Setting new lowered setrlimit cur=0xffffffff max=0xffffffff
After new setrlimit, getrlimit returned cur=0xffffffff max=0xffffffff
Calling exec to test for setrlimit of RLIMIT_DATA
cur=0xffffffff max=0xffffffff)
ERROR: execlp(./dlim) failed: No such file or directory
errno = 2
ERROR: after exec'ed
Original RLIMIT_DATA values:
dlim.rlim_cur = 0x100000000
dlim.rlim_max = 0x100000000

Please let me know what is the issue here..
Looks like dlim executable is not available..

Thanks in Advance,
# 2  
Old 08-10-2009
ENOENT means one of:
1. the file does not exist in the path you specify
2. one of the components of the path you specify does not exist

I would consider NOT using a relative path to dlim like you just did. Create a full file specification -- /my/directory/delim
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command to replace one value which occurs multiple times

Hi, My Input File : "MN." := "MN_13_TM_4" ( 000000110110100100110001111110110110101110101001100111110100011010110111001 ) "MOS." := "MOS_13_TM_4" ( 000000110110100100110001111110110110101110101001100111110100011010110111001 ) Like above template,I have... (4 Replies)
Discussion started by: Preeti Chandra
4 Replies

2. Programming

Problem with fork() and execlp process

Hello everyone, this is my first post. I have a task to use a fork to create multiple processes and then use execlp to run another program to add 2 numbers. The problem I am having is we are supposed to use the exit() call in the execlp to return the small integer. This is a bad way to... (3 Replies)
Discussion started by: Johnathan_1017
3 Replies

3. Programming

How use exec, execlp, ....

Hello, I need to do a function in ansi c for linux that work like command cp.I try with this but doesn't work: int copy (char *src, char *dst) { ret = execlp("/bin/cp", "cp", "/home/linux/working", (char*)src,(char*)dst) return 0; } The copy function must do the next "cp origein.txt... (2 Replies)
Discussion started by: NewBe
2 Replies

4. UNIX for Dummies Questions & Answers

How it work?? the execlp

int main () { int p=1; while (p>0) p=fork(); execlp("prog",prog",Null); return 0; } and thanks :b: (1 Reply)
Discussion started by: foufo07
1 Replies

5. AIX

AIX 5.3: access existing file gives ENOENT

I ran truss on a running java program, and noticed that the access system call was returning "Err#2 ENOENT" for existing files, files that were succesfully "accessed" earlier in the same program, and later on. Is there any reasonable explanation for this behaviour? In the truss... (4 Replies)
Discussion started by: ghp
4 Replies

6. UNIX for Advanced & Expert Users

stty: error occurs when installing rpm

Hello All, when I install rpm rpm --install rpm packagename I got the following errors stty:standard input:invalid argument stty:standard input:invalid argument I dont know what i have to do exactly. I search on google for the same but not a particular standard solution is given... (17 Replies)
Discussion started by: amitpansuria
17 Replies

7. Shell Programming and Scripting

Exiting from script when error occurs

Hi Friends, Is it possible to exit nicely(ie, to echo a message with the error occurred) from a shell script(quiet a big one :)) once it encounter an error in between the lines? For example, in my script I am calling the command mkdir and sometimes (when the directory already exists) it... (4 Replies)
Discussion started by: Sreejith_VK
4 Replies

8. Programming

execlp to sort

Hi, I have a very small program where I call execlp() to execute sort. Everything works fine. But sort has a -T option which can be used to specify a temporary directory. Now when I use -T with execlp() it does not work. #include <stdio.h> #include <stdlib.h> #include <string.h> #include... (4 Replies)
Discussion started by: the_learner
4 Replies

9. HP-UX

error occurs while some users login

hi all, i have a problem that while some of the users trying to login the following error occurs and the session is automatically closed. ssl error: RAND_status reported there wasn't enough randomness for the PRNG. ssl error: You need to specify RandomFile or EGDFile to obtain the randomness.... (0 Replies)
Discussion started by: rrlog
0 Replies

10. Programming

execvp and execlp?

Hi mates, Is there any difference between execvp and execlp? any comment will be appreciated. abdul:) (1 Reply)
Discussion started by: abdul
1 Replies
Login or Register to Ask a Question