Hi,

Am Montag, den 24.08.2020, 01:30 +0200 schrieb Bruno Haible:


On 64-bit Windows, pid_t needs to be 64-bit large, i.e. intptr_t or 'long 
long'or
'__int64'.





This is because the return type of _spawnv* (when invoked with _P_NOWAIT) and
the argument of the _cwait function are 'intptr_t' (see [1][2]: "The return
value from an asynchronous _spawnvp or _wspawnvp (_P_NOWAIT or _P_NOWAITO
specified for mode) is the process handle."



_spawnvp(), or _wspawnvp() are not returning a pid. It is a process handle.

        intptr_t ret = _spawnvp( _P_NOWAIT, argv[2], args );
        DWORD pid = GetProcessId( (HANDLE)ret );
        printf( "ret: %d pid: %d\n", (int)ret, (int)pid );

GetProcessId() returns a DWORD as GetCurrentProcessId() does

[3] 
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreads
api-getprocessid
[4] 
https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreads
api-getcurrentprocessid

So I guess pit_t should be defined as int, or DWORD, or int32_t



On mingw, this is already the case. But on MSVC (and MSVC/clang), the 'pid_t'
type is nowhere defined. In this case, gnulib defines it through config.h.





[1] 
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/spawnvp-wspawnvp
[2] https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/cwait



Regards, Martin




SSI Schäfer IT Solutions GmbH | Friesachstrasse 15 | 8114 Friesach | Austria
Registered Office: Friesach | Commercial Register: 49324 K | VAT no. ATU28654300
Commercial Court: Landesgericht für Zivilrechtssachen Graz
Unsere Hinweise zum Umgang mit personenbezogenen Daten finden Sie 
hier<https://www.ssi-schaefer.com/de-at/datenschutz-49548>.
You can find our information on the handling of personal data 
here<https://www.ssi-schaefer.com/en-at/privacy-13258>.

Reply via email to