This is the mail archive of the
cygwin-talk
mailing list for the cygwin project.
Re: Design mixed 32 and 64 bit systems.
- From: Warren Young <warren at etr-usa dot com>
- To: The Vulgar and Unprofessional Cygwin-Talk List <cygwin-talk at cygwin dot com>
- Date: Mon, 02 Dec 2013 13:44:34 -0700
- Subject: Re: Design mixed 32 and 64 bit systems.
- Authentication-results: sourceware.org; auth=none
- References: <6CF2FC1279D0844C9357664DC5A08BA21D7054 at MLBXV06 dot nih dot gov> <529CE0E4 dot 4080804 at etr-usa dot com> <20131202195626 dot GC604 at ednor dot casa dot cgf dot cx> <529CEDE5 dot 4030703 at etr-usa dot com>
- Reply-to: The Vulgar and Unprofessional Cygwin-Talk List <cygwin-talk at cygwin dot com>
On 12/2/2013 13:30, Warren Young wrote:
On 12/2/2013 12:56, Christopher Faylor wrote:
On Mon, Dec 02, 2013 at 12:35:00PM -0700, Warren Young wrote:
This happens because POSIX PIDs are in a table that lives in
cygwin1.dll's memory space, and because there are two DLLs, there are
two different PID tables.
Actually POSIX pids are Windows PIDs. The distinction becomes fuzzy
after an exec, though, where the Cygwin PID continues to be the PID
of the process which previously exec'ed it.
Of the four PID values this pair of programs prints, shouldn't at least
two should be the same, then? I get four different values here:
PARENT: My PID is 5048; created child PID 5684
CHILD: My PID is 3108; my parent's PID is 1.
I've modified the test programs a bit. The parent can launch either a
32- or 64-bit child, and I've modified the two processes' output so
they're easier to distinguish.
Run without args, parent64 still runs child32, but you can now pass "64"
(i.e. "./parent64 64") to make it run the new child64 program. When you
do that, the output is completely sensible, unlike with the mixed
bitness case:
PARENT64: My PID is 8808; created child PID 3480.
CHILD64: My PID is 3480; my parent's PID is 8808.
Also, doesn't the fact that procps only shows processes running under
the current Cygwin DLL indicate that the process table is DLL-specific?
#include <iostream>
#include <unistd.h>
int main()
{
std::cout << "CHILD32: My PID is " << getpid() <<
"; my parent's PID is " << getppid() << '.' << std::endl;
}
#include <iostream>
#include <unistd.h>
int main()
{
std::cout << "CHILD64: My PID is " << getpid() <<
"; my parent's PID is " << getppid() << '.' << std::endl;
}
#include <iostream>
#include <unistd.h>
#include <errno.h>
#include <string.h>
int main(int argc, char* argv[])
{
std::cout << "PARENT64: My PID is " << getpid() << "; " << std::flush;
switch (int pid = fork()) {
case -1: // error
std::cout << "ERROR: " << strerror(errno) << std::endl;
break;
case 0: { // child
const char* cmd =
(argc > 1 && strcmp(argv[1], "64") == 0) ?
"./child64" :
"./child32";
execl(cmd, cmd, 0);
break;
}
default: // parent
std::cout << "created child PID " << pid << '.' << std::endl;
}
sleep(1);
}