# Linux and macOS

pic targets Linux as much as macOS. The Mac's `ci/test.yml` is the landing check; `ci/linux-nightly.yml`
runs the same `make test-pic` on Linux (gcc, glibc) every night and on demand, reported but not
required. Every path that differs by OS is below, with the test that covers each side. A test that
needs a real tool the machine lacks prints a `SKIP:` line naming it, and passes.

| What | macOS | Linux | Code | Tests |
|------|-------|-------|------|-------|
| The store's key | login Keychain, `/usr/bin/security` | Secret Service, `secret-tool` (needs a session bus) | `src/platform.c:369` `keystore` | `test/pic/keysource.sh`: the stand-in speaks each OS's dialect, checked per OS; on Linux the real `secret-tool` round trip on a private bus and gnome-keyring |
| `pic remote install` | a LaunchAgent, `launchctl` | a systemd user unit, `systemctl --user`; else cron | `src/platform.c:907` `agent_pick`, `:1052` `agent_systemd` | `test/pic/remote-agent.sh`: all three through stand-ins on any OS; `plutil -lint` on the plist (macOS), `systemd-analyze --user verify` on the unit (Linux) |
| Copy | `/usr/bin/pbcopy` | `wl-copy` under Wayland, else `xclip`, else `xsel`; none: OSC 52 | `src/tui/clipboard.c:382` | `test/tui/test_clipboard.c` (`make test-clipboard`): stand-ins on PATH, Linux only; macOS's real pasteboard is never touched |
| Paste | `osascript` (files, image), `pbpaste` | `wl-paste`, else `xclip`, else `xsel`, an image before text | `src/tui/clipboard.c:172`, `:256` | as for copy |
| A durable write | `fcntl(F_FULLFSYNC)`: fsync leaves data in the drive's cache | `fsync`, which flushes the cache on Linux | `src/tools.c:111` `durable_sync` | `test/pic/tools.sh`: on Linux, strace sees the file, its directory and the journal reach fsync; macOS has no unprivileged tracer |
| The journal's sync | `PRAGMA fullfsync=ON` | SQLite's own `fsync` under `synchronous=FULL` | `src/store.c:1779`, `src/userdb.c:408` | `test/pic/test_userdb.c` (the pragma, macOS); `tools.sh`'s strace check (Linux) |
| A stuck `pic remote` loop | the watchdog names the phase it is in | the same | `src/remote.c:169` `rmt_watch_main` | `test/pic/remote_ops.sh` (`stalled for`). Neither OS captures a stack: pic would run a debugger on itself (`sample` on macOS, `gdb` or `eu-stack` on Linux, where Yama's default ptrace scope refuses attaching to a parent), so both report the phase's name instead |
| A process's start time | `sysctl(KERN_PROC)` | `/proc/PID/stat` | `src/procs.c:41` | `test/pic/ps.sh` |
| The host's name for a phone | `scutil --get LocalHostName` | `gethostname` | `src/tui/remote.c:86` | none per OS |
| Key names | Option, Cmd-click | Alt, Ctrl-click | `src/tui/app.c:1246`, `src/tui/keymap.c:27` | none per OS |

Each source also compiles alone under glibc and musl with no `-D` flag
([the amalgamation](amalgamation.md#each-file-alone)).
