You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With runtime.{Lock,Unlock}OSThread and those syscalls, it's possible to handle unix sockets with absolute paths longer than the maximum for a sockaddr_un, by changing the current directory for a single thread and using a relative path, and I'm sure the ability to temporarily change directory without affecting the rest of the program can be useful in other scenarios too.
I'm opening this as a proposal because the fact that the wrappers are internal and the syscalls are double-underscored is a bit sketchy, and I'm not sure if it's ok to go:cgo_import_dynamic the wrapper functions from libSystem.B.dylib even though technically they're in libpthread.
Of note is that x/sys/unix includes the SYS___PTHREAD_CHDIR and SYS___PTHREAD_FCHDIR constants already, but using syscall numbers is deprecated on darwin, afaict.
The text was updated successfully, but these errors were encountered:
Thanks. It's not necessary to open a proposal to add simple syscall wrappers to x/sys/unix. You can just send a patch. Taking this out of the proposal process.
Change https://go.dev/cl/595677 mentions this issue: unix: add PthreadChdir and PthreadFchdir on darwin
ianlancetaylor
changed the title
proposal: x/sys/unix: add PthreadChdir and PthreadFchdir for darwin
x/sys/unix: add PthreadChdir and PthreadFchdir for darwin
Jun 28, 2024
Proposal Details
Darwin has
__pthread_chdir
and__pthread_fchdir
syscalls, wrapped (for internal use) in libpthread aspthread_chdir_np
andpthread_fchdir_np
(https://opensource.apple.com/source/libpthread/libpthread-454.80.2/src/pthread_cwd.c.auto.html), and used (as the latter) by projects such as Chromium. Documentation for the wrappers is also available in a private header file (https://opensource.apple.com/source/libpthread/libpthread-454.80.2/private/pthread/private.h.auto.html).With
runtime.{Lock,Unlock}OSThread
and those syscalls, it's possible to handle unix sockets with absolute paths longer than the maximum for asockaddr_un
, by changing the current directory for a single thread and using a relative path, and I'm sure the ability to temporarily change directory without affecting the rest of the program can be useful in other scenarios too.I'm opening this as a proposal because the fact that the wrappers are internal and the syscalls are double-underscored is a bit sketchy, and I'm not sure if it's ok to
go:cgo_import_dynamic
the wrapper functions fromlibSystem.B.dylib
even though technically they're inlibpthread
.Of note is that x/sys/unix includes the
SYS___PTHREAD_CHDIR
andSYS___PTHREAD_FCHDIR
constants already, but using syscall numbers is deprecated on darwin, afaict.The text was updated successfully, but these errors were encountered: