bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Oberzalek Martin <Martin.Oberzalek@ssi-schaefer.com>
To: "bug-gnulib@gnu.org" <bug-gnulib@gnu.org>
Subject: Re: pid_t on 64-bit Windows
Date: Mon, 31 Aug 2020 08:13:14 +0000	[thread overview]
Message-ID: <1598861594.19486.25.camel@ssi-schaefer.com> (raw)
In-Reply-To: <5981491.j28A7ECyTM@omega>

[-- Attachment #1: Type: text/plain, Size: 2416 bytes --]

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



--

Ing. Martin Oberzalek | Senior Service Technician WAMAS 3 | IT Business Operations

SSI SCHÄFER | SSI Schäfer IT Solutions GmbH | Friesachstraße 15 | 8114 Friesach bei Graz | Austria

Phone +43 3127 200-410 | Fax +43 3127 200-22

martin.oberzalek@ssi-schaefer.com<mailto:firstname.surname@ssi-schaefer.com>

Website<http://www.ssi-schaefer.com/> | Blog<http://www.ssi-schaefer.de/blog/> | YouTube<http://www.youtube.com/user/lagerlogistik1> | Facebook<https://www.facebook.com/SSI.SCHAEFER.DE>

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>.

[-- Attachment #2: Type: text/html, Size: 4274 bytes --]

  reply	other threads:[~2020-08-31 12:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-23 23:30 pid_t on 64-bit Windows Bruno Haible
2020-08-31  8:13 ` Oberzalek Martin [this message]
2020-08-31 14:27   ` Bruno Haible
2020-09-01  1:11     ` Martin Oberzalek
2020-09-01 10:25       ` Bruno Haible
2020-08-31 11:15 ` Oberzalek Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1598861594.19486.25.camel@ssi-schaefer.com \
    --to=martin.oberzalek@ssi-schaefer.com \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).