Solved

Help with execl()

Posted on 1998-05-14
2
172 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

708 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

12 Experts available now in Live!

Get 1:1 Help Now