www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - [possible bug] cwait undefined?

reply Anuj Goyal <Anuj_member pathlink.com> writes:
#include <stdio.h>
#include <process.h>

int main()
{
int pid;
int tstat = 0xdeadbeef;

printf("Running ls with spawnlp\n");
pid = _spawnlp( _P_NOWAIT, "ls", "ls", NULL );

// Suspend our execution until the child has terminated.
// obtain termination code upon completion.
cwait(&tstat, pid, WAIT_CHILD);

printf("\nChild process %d terminated with code 0x%x.\n", pid, tstat);
exit(0);
}

this is the error I get:

D:\ccache-2.3>dmc -WA anuj.c
link anuj,,,user32+kernel32/noi;
OPTLINK (R) for Win32  Release 7.50B1
Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

anuj.obj(anuj)
Error 42: Symbol Undefined _cwait

--- errorlevel 1

However, cwait is defined in c:\dm\include\process.h (line 110)
Jul 17 2004
parent reply "Walter" <newshound digitalmars.com> writes:
spawnlp returns the exit status directly, not the process id. It doesn't
work like unix.

"Anuj Goyal" <Anuj_member pathlink.com> wrote in message
news:cdblcb$1ego$1 digitaldaemon.com...
 #include <stdio.h>
 #include <process.h>

 int main()
 {
 int pid;
 int tstat = 0xdeadbeef;

 printf("Running ls with spawnlp\n");
 pid = _spawnlp( _P_NOWAIT, "ls", "ls", NULL );

 // Suspend our execution until the child has terminated.
 // obtain termination code upon completion.
 cwait(&tstat, pid, WAIT_CHILD);

 printf("\nChild process %d terminated with code 0x%x.\n", pid, tstat);
 exit(0);
 }

 this is the error I get:

 D:\ccache-2.3>dmc -WA anuj.c
 link anuj,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 anuj.obj(anuj)
 Error 42: Symbol Undefined _cwait

 --- errorlevel 1

 However, cwait is defined in c:\dm\include\process.h (line 110)
Jul 17 2004
parent reply Anuj Goyal <Anuj_member pathlink.com> writes:
if there is no way to wait, does the parent process block until the spawnlp'd
process completes? I can test this but thought I would ask the man himself ;)

I got the code from the M$ site:
Appendix G
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnucmg/html/UCMGch09.asp

In article <cdcgus$1q1s$1 digitaldaemon.com>, Walter says...
spawnlp returns the exit status directly, not the process id. It doesn't
work like unix.

"Anuj Goyal" <Anuj_member pathlink.com> wrote in message
news:cdblcb$1ego$1 digitaldaemon.com...
 #include <stdio.h>
 #include <process.h>

 int main()
 {
 int pid;
 int tstat = 0xdeadbeef;

 printf("Running ls with spawnlp\n");
 pid = _spawnlp( _P_NOWAIT, "ls", "ls", NULL );

 // Suspend our execution until the child has terminated.
 // obtain termination code upon completion.
 cwait(&tstat, pid, WAIT_CHILD);

 printf("\nChild process %d terminated with code 0x%x.\n", pid, tstat);
 exit(0);
 }

 this is the error I get:

 D:\ccache-2.3>dmc -WA anuj.c
 link anuj,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 anuj.obj(anuj)
 Error 42: Symbol Undefined _cwait

 --- errorlevel 1

 However, cwait is defined in c:\dm\include\process.h (line 110)
Jul 17 2004
next sibling parent Anuj Goyal <Anuj_member pathlink.com> writes:
nevermind, I guess that can be controlled by these modes:

_P_OVERLAY
Overlays calling process with new process, destroying the calling process (same
effect as _exec calls).
_P_WAIT
Suspends calling thread until execution of new process is complete (synchronous
_spawn).
_P_NOWAIT or _P_NOWAITO
Continues to execute calling process concurrently with new process (asynchronous
_spawn). 
_P_DETACH
Continues to execute the calling process; new process is run in the background
with no access to the console or keyboard. Calls to _cwait against the new
process will fail (asynchronous _spawn). 


In article <cdcmm9$1s10$1 digitaldaemon.com>, Anuj Goyal says...
if there is no way to wait, does the parent process block until the spawnlp'd
process completes? I can test this but thought I would ask the man himself ;)

I got the code from the M$ site:
Appendix G
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnucmg/html/UCMGch09.asp

In article <cdcgus$1q1s$1 digitaldaemon.com>, Walter says...
spawnlp returns the exit status directly, not the process id. It doesn't
work like unix.

"Anuj Goyal" <Anuj_member pathlink.com> wrote in message
news:cdblcb$1ego$1 digitaldaemon.com...
 #include <stdio.h>
 #include <process.h>

 int main()
 {
 int pid;
 int tstat = 0xdeadbeef;

 printf("Running ls with spawnlp\n");
 pid = _spawnlp( _P_NOWAIT, "ls", "ls", NULL );

 // Suspend our execution until the child has terminated.
 // obtain termination code upon completion.
 cwait(&tstat, pid, WAIT_CHILD);

 printf("\nChild process %d terminated with code 0x%x.\n", pid, tstat);
 exit(0);
 }

 this is the error I get:

 D:\ccache-2.3>dmc -WA anuj.c
 link anuj,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 anuj.obj(anuj)
 Error 42: Symbol Undefined _cwait

 --- errorlevel 1

 However, cwait is defined in c:\dm\include\process.h (line 110)
Jul 17 2004
prev sibling parent Anuj Goyal <Anuj_member pathlink.com> writes:
sorry again, I should have looked here in the frist place:
http://www.digitalmars.com/rtl/process.html
In article <cdcmm9$1s10$1 digitaldaemon.com>, Anuj Goyal says...
if there is no way to wait, does the parent process block until the spawnlp'd
process completes? I can test this but thought I would ask the man himself ;)

I got the code from the M$ site:
Appendix G
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnucmg/html/UCMGch09.asp

In article <cdcgus$1q1s$1 digitaldaemon.com>, Walter says...
spawnlp returns the exit status directly, not the process id. It doesn't
work like unix.

"Anuj Goyal" <Anuj_member pathlink.com> wrote in message
news:cdblcb$1ego$1 digitaldaemon.com...
 #include <stdio.h>
 #include <process.h>

 int main()
 {
 int pid;
 int tstat = 0xdeadbeef;

 printf("Running ls with spawnlp\n");
 pid = _spawnlp( _P_NOWAIT, "ls", "ls", NULL );

 // Suspend our execution until the child has terminated.
 // obtain termination code upon completion.
 cwait(&tstat, pid, WAIT_CHILD);

 printf("\nChild process %d terminated with code 0x%x.\n", pid, tstat);
 exit(0);
 }

 this is the error I get:

 D:\ccache-2.3>dmc -WA anuj.c
 link anuj,,,user32+kernel32/noi;
 OPTLINK (R) for Win32  Release 7.50B1
 Copyright (C) Digital Mars 1989 - 2001  All Rights Reserved

 anuj.obj(anuj)
 Error 42: Symbol Undefined _cwait

 --- errorlevel 1

 However, cwait is defined in c:\dm\include\process.h (line 110)
Jul 17 2004