Skip to content

Commit 74c91a6

Browse files
authored
gh-160359: Accept older musl getdents64 buffer declarations (#160365)
Older musl headers expose `getdents64` as an alias for `getdents`, whose buffer parameter is `struct dirent *`. Passing the raw character buffer triggers an incompatible-pointer diagnostic. Pass it through `void *` to support both that interface and the glibc declaration. Ports PBS's [`patch-posixsubprocess-musl-getdents64.patch`](https://github.com/astral-sh/python-build-standalone/blob/0c5e581b54a4736cdbbe68bdd6d7e571a1dca11e/cpython-unix/patch-posixsubprocess-musl-getdents64.patch).
1 parent f3c27a4 commit 74c91a6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎Modules/_posixsubprocess.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,11 @@ _close_open_fds_safe(int start_fd, int *fds_to_keep, Py_ssize_t fds_to_keep_len)
436436
Py_ssize_t bytes;
437437
while (1) {
438438
#ifdef HAVE_GETDENTS64
439-
bytes = getdents64(fd_dir_fd, buffer, sizeof(buffer));
439+
/* musl <1.2.4 headers expose `getdents64` as an alias for `getdents`, whose buffer parameter
440+
* is `struct dirent *`. We use `void *` to support both that interface and the glibc declaration
441+
* without an incompatible-pointer diagnostic.
442+
*/
443+
bytes = getdents64(fd_dir_fd, (void *)buffer, sizeof(buffer));
440444
#else
441445
bytes = syscall(SYS_getdents64, fd_dir_fd,
442446
(struct py_dirent64 *)buffer, sizeof(buffer));

0 commit comments

Comments
 (0)