]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Work around getpid on Windows
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 29 Jun 2021 12:00:33 +0000 (13:00 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Tue, 29 Jun 2021 12:47:59 +0000 (13:47 +0100)
psycopg_c/psycopg_c/pq.pxd
psycopg_c/psycopg_c/pq/pgconn.pyx

index 990d4532b0bf3521b034ab973cb455c3f7bbb04c..82c4e5000dcad238e21c276d1db5c186c621639d 100644 (file)
@@ -1,4 +1,8 @@
-from posix.fcntl cimport pid_t
+IF UNAME_SYSNAME != "Windows":
+    from posix.fcntl cimport pid_t
+ELSE:
+    ctypedef int pid_t
+
 from psycopg_c.pq cimport libpq
 
 ctypedef char *(*conn_bytes_f) (const libpq.PGconn *)
index a0eecb429e51243bd8ee7ef40c12dfb223825391..72f239c34d302480b7acaac27815874e32408ade 100644 (file)
@@ -4,7 +4,14 @@ psycopg_c.pq.PGconn object implementation.
 
 # Copyright (C) 2020-2021 The Psycopg Team
 
-from posix.unistd cimport getpid
+IF UNAME_SYSNAME != "Windows":
+    from posix.unistd cimport getpid
+ELSE:
+    # We don't need a real definition for this because Windows is not affected
+    # by the issue caused by closing the fds after fork.
+    cdef int getpid():
+        return 0
+
 from cpython.mem cimport PyMem_Malloc, PyMem_Free
 from cpython.bytes cimport PyBytes_AsString, PyBytes_AsStringAndSize
 from cpython.memoryview cimport PyMemoryView_FromObject