Thread: execl: Bad Address

  1. #1
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126

    execl: Bad Address

    What does it mean?
    Mac OS 10.6 Snow Leopard : Darwin

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Probably passing a bad pointer to execl() - it's hard to say, because sometimes the error codes from a system call are "reusing a nearby error" instead of creating a new "non-standard" error code.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    My guess is you forgot to add the (char*)0 to the end of the list of arguments.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126

    I have realized that is not execl

    my program writes a file (inside a function, using write and fread).And just after that i run
    Code:
     if(execute(2, tempFileName) ==ERR){	/* executes another program */
    				exit(1);
    			}
    but in that case the program fails ... and says bad address.

    But if i call execute from another program it runs perfectly.
    I suspect that the function that writes the file is not completely correct.

    Can anyone help me with this?

    I posted this problem but no one seems to know...
    http://cboard.cprogramming.com/showthread.php?t=98407

    please help.




    Code:
    static char *program[8] = {
    			"./avgFilter", 
    			"./binarize", 
    			"./invert", 
    			"", "", "", ""};
    
    int execute(short progNumber, char * fileName){
    	int pid;
    	int status;
    	
    	/*
    	 *	Get a child process
    	 */
    	if((pid = fork()) < 0){
    		perror("fork: ");
    		return(-1);
    	}
    	
    	/*
    	 *	The child executes the program
    	 */
    	if(pid == 0){
    		execl(program[progNumber],program[progNumber], fileName, (char *)0);
    		perror("execl");
    		return(-1);
    	}
    	
    	/*
    	 *	The parent process just waits
    	 */
    	if (pid >= 1) {
    		wait(&status);
    	}
    	
    	return(0);
    }
    Mac OS 10.6 Snow Leopard : Darwin

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Can you show the "tempFilename" declaration?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding memory address using memory pattern
    By MindWorX in forum C++ Programming
    Replies: 1
    Last Post: 05-25-2008, 07:20 AM
  2. Memory leaks problem in C -- Help please
    By Amely in forum C Programming
    Replies: 14
    Last Post: 05-21-2008, 11:16 AM
  3. import address table (IAT)
    By George2 in forum C++ Programming
    Replies: 5
    Last Post: 02-20-2008, 08:01 AM
  4. Identify dynamic IP address of network device
    By BobS0327 in forum Tech Board
    Replies: 2
    Last Post: 02-21-2006, 01:49 PM
  5. execl failing
    By carrythe0 in forum C Programming
    Replies: 1
    Last Post: 10-01-2001, 12:25 PM