Solved

Help with execl()

Posted on 1998-05-14
2
177 Views
Last Modified: 2010-04-15
I wrote this program that does a few things and then is supposed to call another program. I tried using system(), but i kept getting a message about "Program too big to fit in memory". So i tried using the function execl(). If i try and run it through a DOS box under win95, works like a charm. But if i try and run it from DOS, it dumps and doesnt run.

Here is the basic pseudo-code:
couple of print statments
call one function
execl("C:\\windows\\scan.exe");

NOw when i run it through does i get a message about an error due to SIGNAL SIGSEVE. What does that mean? ANyone know how i can fix this problem?
0
Comment
Question by:GreatOne
2 Comments
 
LVL 1

Expert Comment

by:marvinm
ID: 1250762
Your call should really be execl("C:\\windows\\scan.exe","C:\\windows\\scan.exe",NULL);
I'm not familiar with SIGNAL SIGSEVE
0
 
LVL 11

Accepted Solution

by:
alexo earned 20 total points
ID: 1250763
SIGSEGV == Illegal storage access. A.k.a. Segment violation.

Check the arguments to execl().  My documentation says:
    int _execl( const char *cmdname, const char *arg0, ... const char *argn, NULL );

Also, I'd suggest using execv() instead of execl()

Example:

    char* prog = "myprog.exe"
    char* args[2] = { prog, NULL };
    execv(prog, args);

If you want to pass command line arguments, make the "args" array bigger and assing the items between the "prog" and the "NULL" to point to the arguments.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now