[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Help with execl()

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
GreatOne
Asked:
GreatOne
1 Solution
 
marvinmCommented:
Your call should really be execl("C:\\windows\\scan.exe","C:\\windows\\scan.exe",NULL);
I'm not familiar with SIGNAL SIGSEVE
0
 
alexoCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now