Thread overview
spawnl problem
Mar 20, 2005
Sergiy Yakovyn
Apr 18, 2005
Walter
Mar 12, 2006
Sergiy Yakovyn
Jul 20, 2007
%u
March 20, 2005
Hi all!
Next code:
#include <stdio.h>
#include <process.h>
#include <stdlib.h>

int main()
{
  char const* progName="Test.exe";
  int ret=spawnl(P_WAIT, progName, progName, 0);
  printf("RunProg::run: %s %d %d %d\n", progName, ret, errno, _doserrno);
  return 0;
}

after compiling with dm compiler (Digital Mars Compiler Version 8.41n) and
using sdl.lib (19.03.2003  11:42           397 312 sdl.lib)
by bat file with next contenst:

set path=d:\dm\bin
dmc -o -4 -ml TstRunPg.cpp
del *.obj

I get next output:
RunProg::run: Test.exe -1 7 0

I can't understand what is my fault.
I've tried this program under bc 3.1 and it runs Test.exe.
Please help me!

Sergiy Yakovyn


April 18, 2005
Use NULL, not 0, to terminate the argument list to spawnl:

    int ret=spawnl(P_WAIT, progName, progName, NULL);

Then it works. NULL is a 4 byte value with the L memory model, whereas 0 is 2 bytes.


March 12, 2006
int ret=spawnl(P_WAIT, progName, progName, NULL);
The example above doesn't work.
Work only when I've written as below:
spawnl(P_WAIT, mProgName, mProgName, NULL, NULL).
It looks like NULL is two bytes value at large model under some
circumstance.
I am using next files:
#include <process.h>
#include <stdlib.h>
#include <types.h>

I think it's because next definition in stdlib.h (I compile C++ file). For C
files you are right.
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif

"Walter" <newshound@digitalmars.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:d40oac$1eam$1@digitaldaemon.com...
> Use NULL, not 0, to terminate the argument list to spawnl:
>
>    int ret=spawnl(P_WAIT, progName, progName, NULL);
>
> Then it works. NULL is a 4 byte value with the L memory model, whereas 0
> is
> 2 bytes.
>
>



July 20, 2007
give me example of spawnl function