I wrote up a small CLI tool that automates backing up some data in docker containers. Part of it involves attaching to the container to issue a couple commands to the service's console, which requires using a TTY/PTY. To do this on macOS, I used
posix_openpt/grantpt/unlockpt/ptsname from the Darwin library, and provide the file handle to
The ugly bit is that I'm now attempting to run this tool on Ubuntu 20.04, where I'm not paying for the overhead of hyperkit. My thinking was that everything I was using should be available on Linux. Unfortunately, it looks like these above functions are not part of Glibc, and I can't find any similar functions under different names that it might have exported. getpt() isn't available either.
So my next step was to create a system library module that defines _GNU_SOURCE (to light up the PTY functions I want) and imported stdlib.h and fcntl.h. Tested this using a C file with Swift's copy of clang first, including only my bridging header, and it worked fine there. However, even though Swift doesn't seem to complain about the system library itself at build time, it still complains about the missing symbols, so it's possible something with the module map is mis-configured.
In a package that only has the system library, I can't even seem to use the REPL on it like you can a package that exports a normal library, so inspecting the result there isn't seemingly working.
Is there perhaps a better way to get at a PTY on Linux? Or some way to properly test to see what is actually going on with the system library module to understand why the symbols aren't getting found?