Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

_spawnlp returns E2BIG

Posted on 1998-06-17
8
Medium Priority
?
465 Views
Last Modified: 2008-02-01
I am writing a DOS program using MSVC 1.52, large memory model. The DOS program is running under W95.

I make a call, similar to:-

retval = _spawnlp(_P_WAIT, "notepad", "notepad", NULL);

retval returns -1
errno equals 7 (E2BIG)

This is likely because there is not enough memory to spawn the new process. If this *is* the problem, how do I free up memory in a DOS program to allow the _spawnlp to run.

This program has worked in the past on a different machine, I don't know what is different this time.
0
Comment
Question by:icd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:elfie
ID: 1251257
First try to find out what the available memory is just before the spawn function. Doe sit need to run in the same dos box, or is it possible to start it in another box?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1251258
E2BIG means that the argument list is too long (no memory is ENOMEM).  Which is strange, since the call seems OK to me.  Hmmm...  Tried "notepad.exe"?
0
 
LVL 5

Author Comment

by:icd
ID: 1251259
As I understand it, a DOS program by default takes the maximum available (640k) memory. I am assuming that this is the reason why the 'notepad' (or any program in fact) cannot run.

The meaning of E2BIG is 'In MS-DOS, the argument list exceeds 18 bytes (not so), or the space required for the environment information exceeds 32K' (unlikely).

I see now that ENOMEM is the error I would expect if there were not enough memory, so what is going on?

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Expert Comment

by:kinkajou
ID: 1251260
You might want to try increasing your environment. Some of the steps I have taken to solve DOS memory problems are:

Add "SHELL=C:\COMMAND.COM C:\ /E:4096 /P" to CONFIG.SYS

Then I go to the process's icon in Windows and select properties and memory to adjust all of the memory settings to their maximum.
0
 
LVL 5

Author Comment

by:icd
ID: 1251261
kinkajou.

That solution was what I was hoping for, however it does not seem to have had any effect. I still get errno 7 (E2BIG).


0
 
LVL 1

Accepted Solution

by:
shivers earned 400 total points
ID: 1251262
I've been having this problem recently - I found it worked sporadically like that, but doing it like this seems to work fine:

if (spawnl(P_WAIT, "proggie.exe", NULL, NULL) == -1) {
  printf("Spawn Error!\n");
  exit(1);
};

(i.e. with a null instead of the second copy of the program name.  I'm not really sure why this should make a difference, but it works on mine ;)


0
 
LVL 5

Author Comment

by:icd
ID: 1251263
Shivers

Thanks for that reply. It was close enought to put me on the right track. The actual line I came up with in the end was:-

_spawnlp(_P_WAIT, "xcopy", "xcopy", "c:\\from", "c:\\to", NULL, NULL);

It is the two NULLs at the end that are significant, not the NULL for arg[0].

Thanks a lot.

0
 
LVL 11

Expert Comment

by:alexo
ID: 1251264
Doh!  Can anyone comment on that?  Requiring two NULLS seems like sheer stupidity.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

705 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