Thanks!x

On Mon, Apr 24, 2017 at 06:11:52PM +0000, Alin Serdean wrote:
> It turns out _getpid (https://msdn.microsoft.com/en-us/library/t2y34y40.aspx) 
> actually calls GetCurrentProcessId 
> (https://msdn.microsoft.com/en-us/library/windows/desktop/ms683180(v=vs.85).aspx).
> 
> I created small test binary and added a breakpoint for GetCurrentProcessId.
> bm KERNEL32!GetCurrentProcessId
> 
> 0:000> k
>  # Child-SP          RetAddr           Call Site
> 00 000000e2`5054fbb8 00007ffa`7efe056a KERNEL32!GetCurrentProcessId
> 01 000000e2`5054fbc0 00007ff6`0edc1037 MSVCR120D!getpid+0xa
> 02 000000e2`5054fbf0 00007ff6`0edc13ad ConsoleApplication10!wmain+0x27
> 0:000> bl
>  1 e 00007ffa`9f771e70     0001 (0001)  0:**** KERNEL32!GetCurrentProcessId
> 
> IMO this should guarantee the result of GetCurrentProcessId to an int is ok.
> 
> I'll respin the patches using the inline function as you suggested Ben. I'll 
> also add you as co-author and add a caveat on top (so we remember about it).
> 
> Thanks,
> Alin.
> 
> 
> > -----Original Message-----
> > From: ovs-dev-boun...@openvswitch.org [mailto:ovs-dev-
> > boun...@openvswitch.org] On Behalf Of Alin Serdean
> > Sent: Wednesday, April 19, 2017 8:03 AM
> > To: Ben Pfaff <b...@ovn.org>
> > Cc: d...@openvswitch.org
> > Subject: Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid and
> > getcwd
> > 
> > The documentation is somewhat unclear on it. I'll try to expand
> > getpid/GetCurrentProcessId to see if they call the same things under the
> > scenes (one would assume yes), and let you know.
> > 
> > Thanks,
> > Alin.
> > 
> > > -----Original Message-----
> > > From: Ben Pfaff [mailto:b...@ovn.org]
> > > Sent: Wednesday, April 19, 2017 7:55 AM
> > > To: Alin Serdean <aserd...@cloudbasesolutions.com>
> > > Cc: Sairam Venugopal <vsai...@vmware.com>; d...@openvswitch.org
> > > Subject: Re: [ovs-dev] [PATCH 02/10] windows: add definition of getpid
> > > and getcwd
> > >
> > > I don't know how much risk there is.  If the values actually returned
> > > in practice as process IDs by GetCurrentProcessId() are all in the
> > > range 0...INT_MAX, then it's fine to use the implementation I
> > > suggested.  But if it might return any value, then it is safer to use 
> > > _getpid().
> > >
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to