The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > HP-UX
.
google unix.com



HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
stty: error occurs when installing rpm amitpansuria UNIX for Advanced & Expert Users 17 09-25-2008 12:30 AM
Exiting from script when error occurs Sreejith_VK Shell Programming and Scripting 4 04-25-2008 03:53 AM
execlp to sort the_learner High Level Programming 4 11-29-2007 01:50 AM
error occurs while some users login rrlog HP-UX 0 08-12-2007 04:55 PM
execvp and execlp? abdul High Level Programming 1 09-04-2001 09:33 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-10-2009
mansa mansa is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 33
ENOENT error occurs while issueing execlp command

Code:

/************************************************************************
*
* 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;
main()
{
if (getuid()) {
fprintf(stderr, "ERROR: test must be run as root\n");
exit(11);
}
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("----------------------------\n");
printf("dlim.rlim_cur = 0x%lx\n", org_dcur);
printf("dlim.rlim_max = 0x%lx\n", org_dmax);
printf("\n");
printf("\nTest: Lower cur, max RLIMIT_DATA by 1, then call exec\n");
fflush(stdout);
/* (cur,max) (cur,max) */
/* uid, init limits, new limits */
func( 1, org_dcur, org_dmax, dcur, dmax);
exit(0);
}
void
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);
exit(1);
}
else if (child) { /*parent*/
waitpid(child, &status, 0);
if (WEXITSTATUS(status)) /* If test failed */
exit(WEXITSTATUS(status));
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("===============================\n");
printf("| Begin test with RLIMIT_DATA |\n");
printf("===============================\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);
exit(2);
}

if ( (id) && (setuid(id) == -1) ) {
perror("ERROR: setuid failed");
printf("errno = %d\n", errno);
exit(3);
}
printf("Setting new lowered setrlimit ");
printf("cur=0x%lx max=0x%lx\n", cur, max);
fflush(stdout);
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);
exit(4);
}

/*
*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);
exit(5);
}
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);
exit(6);
} 
/* 
* 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));
*/
fflush(stdout);
/*
* Set up a grandchild to perform the exec call.
*
*/
if ((g_child=fork()) == (pid_t)-1) {
perror("ERROR: fork");
exit(11);
}
else if (g_child) { /*parent*/
waitpid(g_child, &status, 0);
if (WEXITSTATUS(status)) { /* If test failed */
if (WEXITSTATUS(status)==EWRONGLIM)
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");
else
fprintf(stderr, "ERROR: after exec'ed\n"); 
exit(WEXITSTATUS(status));
}
if (WIFSIGNALED(status)) /* If test died from signal */
raise(WTERMSIG(status)); /*parent gets it too */
printf("\n");
fflush(stdout);
exit(0);
}
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);
exit(12);
}
else {
perror("ERROR: shouldn't be returned here from the exec() call!");
printf("errno = %d\n", errno);
exit(13);
}
}
printf("\n");
fflush(stdout);
exit(0);
}
}
 

Hi,

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,
Mansa
  #2 (permalink)  
Old 08-10-2009
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
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
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0