On Snap

Snap is a package manager that is gaining popularity. It's promoted by Canonical, the company behind Ubuntu.

I was playing with it to see what makes it special. I decided to experiment with zig and snap. My reasons for selecting zig are not particularly important.

Installing using snap

Easy enough:

snap install zig

Ok. ..fuck.. nope you get an error you must choose a channel --edge or --beta.

Ok easy enough, I picked beta:

snap install --beta zig

OK.. Fuck again. nope you have to, for some reason, choose --classic flag.

Ok :

snap install --beta --classic zig

Finally installed.

Now I wanted to see what it did. I expected the zig command to be available in my environment, so I ran:

zig

It worked. I got the expected help text. Gr8.

Inspecting installed package

Now that the zig is installed I wanted to see how where what it did.. First where:

which zig

Ok that seems fine I get: /snap/bin/zig. Didn't expect /snap prefixed. But I guess that's fine

Then I wanted to see what it was:

file /snap/bin/zig

And I get:

/snap/bin/zig: symbolic link to /usr/bin/snap

Holy fucking shit! zig is just a symlink to snap! Snap has zig integrated in itself! Wtf is this? There are two implementations of zig!

Ok. this was not expected. I wanted to see how it does the thing it does.

strace zig

Horror

Analyzing the syscalls you can see what the app does. strace is a tool to do such things. strace is a great tool. Good Job to whoever made it.

First execve syscalls:

execve("/snap/bin/zig", ["zig"], 0x7ffd04d941d0 /* 28 vars */) = 0
execve("/usr/lib/snapd/snap-confine", ["/usr/lib/snapd/snap-confine", "--classic", "--base", "bare", "snap.zig.zig", "/usr/lib/snapd/snap-exec", "zig.zig"], 0xc00036e600 /* 44 vars */) = 0
execve("/usr/lib/snapd/snap-exec", ["/usr/lib/snapd/snap-exec", "zig.zig"], 0x5626433f9a30 /* 46 vars */) = 0
execve("/snap/zig/11625/zig", ["/snap/zig/11625/zig"], 0xc00020c180 /* 46 vars */) = 0

So first /snap/bin/zig ( /usr/bin/snap ) is executed. Then it calls /usr/lib/snapd/snap-confine. Which calls /usr/lib/snapd/snap-exec. That finally calls /snap/zig/11625/zig and that, in fact, is the real zig compiler.

Openat syscalls:

openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", O_RDONLY) = 3
openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/share/locale-langpack/en_GB/LC_MESSAGES/snappy.mo", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/proc/cgroups", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/proc/cmdline", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/snap/snapd/current/usr/lib/snapd/info", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/proc/sys/crypto/fips_enabled", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/snapd/snapd", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/caps", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/dbus", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/domain", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/domain/attach_conditions", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/file", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/ipc", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/mount", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/namespaces", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/network", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/network_v8", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/policy", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/policy/versions", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/ptrace", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/query", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/query/label", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/rlimit", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/signal", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/policy/permstable32", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/sys/kernel/security/apparmor/features/policy/notify/user", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/proc/self/mountinfo", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/etc/fstab", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/proc/self/mountinfo", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/proc/sys/kernel/seccomp/actions_avail", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/dev/null", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/var/lib/snapd/system-key", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/var/lib/snapd/inhibit/zig.lock", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 7
openat(AT_FDCWD, "/snap/zig/11625/meta/snap.yaml", O_RDONLY|O_CLOEXEC) = 8
openat(AT_FDCWD, "/var/lib/snapd/sequence/zig.json", O_RDONLY|O_CLOEXEC) = 8
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 8
openat(AT_FDCWD, "/etc/passwd", O_RDONLY|O_CLOEXEC) = 8
openat(AT_FDCWD, "/proc/self/mountinfo", O_RDONLY|O_CLOEXEC) = 8
openat(AT_FDCWD, "/proc/6835/cgroup", O_RDONLY|O_CLOEXEC) = 8
openat(AT_FDCWD, "/proc/sys/kernel/random/uuid", O_RDONLY|O_CLOEXEC) = 9
openat(AT_FDCWD, "/proc/6835/cgroup", O_RDONLY|O_CLOEXEC) = 9
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libudev.so.1", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, ".", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH|O_DIRECTORY) = 3
openat(AT_FDCWD, "/var/lib/snapd/cookie/snap.zig", O_RDONLY|O_NOFOLLOW|O_CLOEXEC) = 4
openat(AT_FDCWD, "/sys/module/apparmor/parameters/enabled", O_RDONLY) = 4
openat(AT_FDCWD, "/proc/mounts", O_RDONLY|O_CLOEXEC) = 4
openat(AT_FDCWD, "/proc/6835/attr/apparmor/current", O_RDONLY) = 4
openat(AT_FDCWD, "/var/lib/snapd/features", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH|O_DIRECTORY) = 4
openat(AT_FDCWD, "/var/lib/snapd/features", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH|O_DIRECTORY) = 4
openat(AT_FDCWD, "/", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 4
openat(4, "root", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 5
openat(5, "snap", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 4
openat(4, "zig", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 5
openat(5, "11625", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = 4
openat(AT_FDCWD, "/proc/6835/attr/apparmor/exec", O_WRONLY) = 4
openat(AT_FDCWD, "/var/lib/snapd/seccomp/bpf//snap.zig.zig.bin2", O_RDONLY) = 4
openat(AT_FDCWD, "/root", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH|O_DIRECTORY) = 4
openat(AT_FDCWD, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", O_RDONLY) = 3
openat(AT_FDCWD, "/etc/os-release", O_RDONLY|O_CLOEXEC) = 3
openat(AT_FDCWD, "/usr/share/locale-langpack/en_GB/LC_MESSAGES/snappy.mo", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/proc/cmdline", O_RDONLY|O_CLOEXEC) = 7
openat(AT_FDCWD, "/snap/zig/11625/meta/snap.yaml", O_RDONLY|O_CLOEXEC) = 7

68 Files opened that have nothing to do with zig. libc Is for some reason opened twice. I have no Idea what any of this files are. Why do you need /etc/passwd file to open zig? What are all this yaml files. Why do you nedd zig.lock? Who are you locking it against? Wtf is apparmor?

read syscall:

read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\237\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0 \0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0"..., 48, 848) = 48
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0I\17\357\204\3$\f\221\2039x\324\224\323\236S"..., 68, 896) = 68
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
read(3, "2097152\n", 20)                = 8
read(3, "PRETTY_NAME=\"Ubuntu 22.04.5 LTS\""..., 4096) = 386
read(3, "", 3710)                       = 0
read(7, "\336\22\4\225", 4)             = 4
read(7, "\0\0\0\0\"\0\0\0\34\0\0\0,\1\0\0/\0\0\0\2\0\0\0\0\0\0\370\2\0\0", 32) = 32
read(7, "\0\0\0\0\370\2\0\0", 8)        = 8
read(7, "\337\1\0\0\225\26\0\0", 8)     = 8
read(7, "Project-Id-Version: snapd\nReport"..., 479) = 479
read(7, "K\1\0\0\371\2\0\0", 8)         = 8
read(7, "I\1\0\0u\30\0\0", 8)           = 8
read(7, "\nThe ack command tries to add an"..., 331) = 331
read(7, "\nThe ack command tries to add an"..., 329) = 329
read(7, "^\1\0\0E\4\0\0", 8)            = 8
read(7, "^\1\0\0\277\31\0\0", 8)        = 8
read(7, "\nThe console-conf-start command "..., 350) = 350
read(7, "\nThe console-conf-start command "..., 350) = 350
read(7, "\254\1\0\0\244\5\0\0", 8)      = 8
read(7, "\255\1\0\0\36\33\0\0", 8)      = 8
read(7, "\nThe find command queries the st"..., 428) = 428
read(7, "\nThe find command queries the st"..., 429) = 429
read(7, "\314\0\0\0Q\7\0\0", 8)         = 8
read(7, "\315\0\0\0\314\34\0\0", 8)     = 8
read(7, "\nThe list command displays a sum"..., 204) = 204
read(7, "\nThe list command displays a sum"..., 205) = 205
read(7, "9\2\0\0\36\10\0\0", 8)         = 8
read(7, "B\2\0\0\232\35\0\0", 8)        = 8
read(7, "\nThe publisher of snap %q has in"..., 569) = 569
read(7, "\nThe publisher of snap %q has in"..., 578) = 578
read(7, "\322\1\0\0X\n\0\0", 8)         = 8
read(7, "\323\1\0\0\335\37\0\0", 8)     = 8
read(7, "\nThe reboot command can used fro"..., 466) = 466
read(7, "\nThe reboot command can used fro"..., 467) = 467
read(7, "\254\1\0\0+\f\0\0", 8)         = 8
read(7, "\255\1\0\0\261!\0\0", 8)       = 8
read(7, "\nThe reboot command reboots the "..., 428) = 428
read(7, "\nThe reboot command reboots the "..., 429) = 429
read(7, "\352\1\0\0\330\r\0\0", 8)      = 8
read(7, "\354\1\0\0_#\0\0", 8)          = 8
read(7, "\nThe remodel command changes the"..., 490) = 490
read(7, "\nThe remodel command changes the"..., 492) = 492
read(7, "&\1\0\0\303\17\0\0", 8)        = 8
read(7, "'\1\0\0L%\0\0", 8)             = 8
read(7, "\nThis revision of snap %q was pu"..., 294) = 294
read(7, "\nThis revision of snap %q was pu"..., 295) = 295
read(7, "\"\0\0\0\352\20\0\0", 8)       = 8
read(7, "!\0\0\0t&\0\0", 8)             = 8
read(7, "Allow snap %q to change %s to %q"..., 34) = 34
read(7, "Allow snap %q to change %s to %q"..., 33) = 33
read(7, "&\0\0\0\r\21\0\0", 8)          = 8
read(7, "'\0\0\0\226&\0\0", 8)          = 8
read(7, "An email of a user on login.ubun"..., 38) = 38
read(7, "An e-mail of a user on login.ubu"..., 39) = 39
read(7, "\0\0\0004\21\0\0", 8)         = 8
read(7, "\0\0\0\276&\0\0", 8)          = 8
read(7, "Authorization is required to aut"..., 60) = 60
read(7, "Authorisation is required to aut"..., 60) = 60
read(7, ")\0\0\0q\21\0\0", 8)           = 8
read(7, "*\0\0\0\373&\0\0", 8)          = 8
read(7, "Control the reboot behavior of t"..., 41) = 41
read(7, "Control the reboot behaviour of "..., 42) = 42
read(7, "\17\0\0\0\233\21\0\0", 8)      = 8
read(7, "\20\0\0\0&'\0\0", 8)           = 8
read(7, "Email address: ", 15)          = 15
read(7, "E-mail address: ", 16)         = 16
read(7, ",\0\0\0\253\21\0\0", 8)        = 8
read(7, ",\0\0\0007'\0\0", 8)           = 8
read(7, "Image customizations specified a"..., 44) = 44
read(7, "Image customisations specified a"..., 44) = 44
read(7, "\21\0\0\0\330\21\0\0", 8)      = 8
read(7, "\21\0\0\0d'\0\0", 8)           = 8
read(7, "Initialize device", 17)        = 17
read(7, "Initialise device", 17)        = 17
read(7, "\25\0\0\0\352\21\0\0", 8)      = 8
read(7, "\31\0\0\0v'\0\0", 8)           = 8
read(7, "Name of key to delete", 21)    = 21
read(7, "Name of key to be deleted", 25) = 25
read(7, "#\0\0\0\0\22\0\0", 8)          = 8
read(7, "%\0\0\0\220'\0\0", 8)          = 8
read(7, "Perform factory reset of the sys"..., 35) = 35
read(7, "Perform a factory reset of the s"..., 37) = 37
read(7, "a\0\0\0$\22\0\0", 8)           = 8
read(7, "f\0\0\0\266'\0\0", 8)          = 8
read(7, "Please be mindful pre-release ch"..., 97) = 97
read(7, "Please be mindful that pre-relea"..., 102) = 102
read(7, "_\0\0\0\206\22\0\0", 8)        = 8
read(7, "_\0\0\0\35(\0\0", 8)           = 8
read(7, "Please re-enter your Ubuntu One "..., 95) = 95
read(7, "Please re-enter your Ubuntu One "..., 95) = 95
read(7, "\32\0\0\0\346\22\0\0", 8)      = 8
read(7, "\33\0\0\0}(\0\0", 8)           = 8
read(7, "Print the version and exit", 26) = 26
read(7, "Print the version, and exit", 27) = 27
read(7, "\221\0\0\0\1\23\0\0", 8)       = 8
read(7, "\221\0\0\0\231(\0\0", 8)       = 8
read(7, "Run the command under strace (us"..., 145) = 145
read(7, "Run the command under strace (us"..., 145) = 145
read(7, "\26\1\0\0\223\23\0\0", 8)      = 8
read(7, "\27\1\0\0+)\0\0", 8)           = 8
read(7, "Select last change of given type"..., 278) = 278
read(7, "Select last change of given type"..., 279) = 279
read(7, "4\0\0\0\252\24\0\0", 8)        = 8
read(7, "6\0\0\0C*\0\0", 8)             = 8
read(7, "Set id of snapshot to delete (se"..., 52) = 52
read(7, "Set ID of snapshot to delete (se"..., 54) = 54
read(7, "\34\0\0\0\337\24\0\0", 8)      = 8
read(7, "\34\0\0\0z*\0\0", 8)           = 8
read(7, "Set id of snapshot to export", 28) = 28
read(7, "Set ID of snapshot to export", 28) = 28
read(7, "5\0\0\0\374\24\0\0", 8)        = 8
read(7, "7\0\0\0\227*\0\0", 8)          = 8
read(7, "Set id of snapshot to restore (s"..., 53) = 53
read(7, "Set ID of snapshot to restore (s"..., 55) = 55
read(7, "4\0\0\0002\25\0\0", 8)         = 8
read(7, "6\0\0\0\317*\0\0", 8)          = 8
read(7, "Set id of snapshot to verify (se"..., 52) = 52
read(7, "Set ID of snapshot to verify (se"..., 54) = 54
read(7, "&\0\0\0g\25\0\0", 8)           = 8
read(7, "'\0\0\0\6+\0\0", 8)            = 8
read(7, "The login.ubuntu.com email to lo"..., 38) = 38
read(7, "The login.ubuntu.com e-mail to l"..., 39) = 39
read(7, "C\0\0\0\216\25\0\0", 8)        = 8
read(7, "E\0\0\0.+\0\0", 8)             = 8
read(7, "This dialog will close automatic"..., 67) = 67
read(7, "This dialogue will close automat"..., 69) = 69
read(7, "3\0\0\0\322\25\0\0", 8)        = 8
read(7, "4\0\0\0t+\0\0", 8)             = 8
read(7, "Use a little bit of color to hig"..., 51) = 51
read(7, "Use a little bit of colour to hi"..., 52) = 52
read(7, "\6\0\0\0\6\26\0\0", 8)         = 8
read(7, "\7\0\0\0\251+\0\0", 8)         = 8
read(7, "email:", 6)                    = 6
read(7, "e-mail:", 7)                   = 7
read(7, "f\0\0\0\r\26\0\0", 8)          = 8
read(7, "h\0\0\0\261+\0\0", 8)          = 8
read(7, "invalid argument for snapshot se"..., 102) = 102
read(7, "invalid argument for snapshot se"..., 104) = 104
read(7, " \0\0\0t\26\0\0", 8)           = 8
read(7, " \0\0\0\32,\0\0", 8)           = 8
read(7, "snap %q has no updates available", 32) = 32
read(7, "snap %q has no available updates", 32) = 32
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/bin/snap", 128) = 13
read(7, "#subsys_name\thierarchy\tnum_cgrou"..., 4096) = 240
read(7, "BOOT_IMAGE=/boot/vmlinuz-5.15.0-"..., 512) = 153
read(7, "", 359)                        = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/bin/snap", 128) = 13
read(7, "VERSION=2.66.1\nSNAPD_APPARMOR_RE"..., 4096) = 118
read(7, "", 3978)                       = 0
readlinkat(AT_FDCWD, "/snap/bin/zig", "/usr/bin/snap", 128) = 13
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/bin/snap", 128) = 13
pread64(7, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0", 16, 0) = 16
pread64(7, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0ps\36\0\0\0\0\0"..., 64, 0) = 64
pread64(7, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 56, 64) = 56
pread64(7, "\3\0\0\0\4\0\0\0P\3\0\0\0\0\0\0P\3\0\0\0\0\0\0P\3\0\0\0\0\0\0"..., 56, 120) = 56
pread64(7, "\1\0\0\0\4\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 56, 176) = 56
pread64(7, "\1\0\0\0\5\0\0\0\0p\36\0\0\0\0\0\0p\36\0\0\0\0\0\0p\36\0\0\0\0\0"..., 56, 232) = 56
pread64(7, "\1\0\0\0\4\0\0\0\0000\300\0\0\0\0\0\0000\300\0\0\0\0\0\0000\300\0\0\0\0\0"..., 56, 288) = 56
pread64(7, "\1\0\0\0\6\0\0\0\360j\346\0\0\0\0\0\360z\346\0\0\0\0\0\360z\346\0\0\0\0\0"..., 56, 344) = 56
pread64(7, "\2\0\0\0\6\0\0\0000\34b\1\0\0\0\0000,b\1\0\0\0\0000,b\1\0\0\0\0"..., 56, 400) = 56
pread64(7, "\4\0\0\0\4\0\0\0p\3\0\0\0\0\0\0p\3\0\0\0\0\0\0p\3\0\0\0\0\0\0"..., 56, 456) = 56
pread64(7, "\4\0\0\0\4\0\0\0\220\3\0\0\0\0\0\0\220\3\0\0\0\0\0\0\220\3\0\0\0\0\0\0"..., 56, 512) = 56
pread64(7, "\7\0\0\0\4\0\0\0\360j\346\0\0\0\0\0\360z\346\0\0\0\0\0\360z\346\0\0\0\0\0"..., 56, 568) = 56
pread64(7, "S\345td\4\0\0\0p\3\0\0\0\0\0\0p\3\0\0\0\0\0\0p\3\0\0\0\0\0\0"..., 56, 624) = 56
pread64(7, "P\345td\4\0\0\0\250`\346\0\0\0\0\0\250`\346\0\0\0\0\0\250`\346\0\0\0\0\0"..., 56, 680) = 56
pread64(7, "Q\345td\6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 56, 736) = 56
pread64(7, "R\345td\4\0\0\0\360j\346\0\0\0\0\0\360z\346\0\0\0\0\0\360z\346\0\0\0\0\0"..., 56, 792) = 56
pread64(7, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 64, 23575488) = 64
pread64(7, "\v\0\0\0\1\0\0\0\2\0\0\0\0\0\0\0P\3\0\0\0\0\0\0P\3\0\0\0\0\0\0"..., 64, 23575552) = 64
pread64(7, "\23\0\0\0\7\0\0\0\2\0\0\0\0\0\0\0p\3\0\0\0\0\0\0p\3\0\0\0\0\0\0"..., 64, 23575616) = 64
pread64(7, "&\0\0\0\7\0\0\0\2\0\0\0\0\0\0\0\220\3\0\0\0\0\0\0\220\3\0\0\0\0\0\0"..., 64, 23575680) = 64
pread64(7, "9\0\0\0\7\0\0\0\2\0\0\0\0\0\0\0\264\3\0\0\0\0\0\0\264\3\0\0\0\0\0\0"..., 64, 23575744) = 64
pread64(7, "G\0\0\0\7\0\0\0\2\0\0\0\0\0\0\0\324\3\0\0\0\0\0\0\324\3\0\0\0\0\0\0"..., 64, 23575808) = 64
pread64(7, "X\0\0\0\366\377\377o\2\0\0\0\0\0\0\08\4\0\0\0\0\0\08\4\0\0\0\0\0\0"..., 64, 23575872) = 64
pread64(7, "b\0\0\0\v\0\0\0\2\0\0\0\0\0\0\0\0\6\0\0\0\0\0\0\0\6\0\0\0\0\0\0"..., 64, 23575936) = 64
pread64(7, "j\0\0\0\3\0\0\0\2\0\0\0\0\0\0\0\200\20\0\0\0\0\0\0\200\20\0\0\0\0\0\0"..., 64, 23576000) = 64
pread64(7, "r\0\0\0\377\377\377o\2\0\0\0\0\0\0\0\370\26\0\0\0\0\0\0\370\26\0\0\0\0\0\0"..., 64, 23576064) = 64
pread64(7, "\177\0\0\0\376\377\377o\2\0\0\0\0\0\0\0\330\27\0\0\0\0\0\0\330\27\0\0\0\0\0\0"..., 64, 23576128) = 64
pread64(7, "\216\0\0\0\4\0\0\0\2\0\0\0\0\0\0\0H\30\0\0\0\0\0\0H\30\0\0\0\0\0\0"..., 64, 23576192) = 64
pread64(7, "\230\0\0\0\4\0\0\0B\0\0\0\0\0\0\0\10g\36\0\0\0\0\0\10g\36\0\0\0\0\0"..., 64, 23576256) = 64
pread64(7, "\242\0\0\0\1\0\0\0\6\0\0\0\0\0\0\0\0p\36\0\0\0\0\0\0p\36\0\0\0\0\0"..., 64, 23576320) = 64
pread64(7, "\235\0\0\0\1\0\0\0\6\0\0\0\0\0\0\0 p\36\0\0\0\0\0 p\36\0\0\0\0\0"..., 64, 23576384) = 64
pread64(7, "\250\0\0\0\1\0\0\0\6\0\0\0\0\0\0\0Ps\36\0\0\0\0\0Ps\36\0\0\0\0\0"..., 64, 23576448) = 64
pread64(7, "\261\0\0\0\1\0\0\0\6\0\0\0\0\0\0\0`s\36\0\0\0\0\0`s\36\0\0\0\0\0"..., 64, 23576512) = 64
pread64(7, "\267\0\0\0\1\0\0\0\6\0\0\0\0\0\0\0\350%\300\0\0\0\0\0\350%\300\0\0\0\0\0"..., 64, 23576576) = 64
pread64(7, "\275\0\0\0\1\0\0\0\2\0\0\0\0\0\0\0\0000\300\0\0\0\0\0\0000\300\0\0\0\0\0"..., 64, 23576640) = 64
pread64(7, "\305\0\0\0\1\0\0\0\2\0\0\0\0\0\0\0\250`\346\0\0\0\0\0\250`\346\0\0\0\0\0"..., 64, 23576704) = 64
pread64(7, "\323\0\0\0\1\0\0\0\2\0\0\0\0\0\0\0(b\346\0\0\0\0\0(b\346\0\0\0\0\0"..., 64, 23576768) = 64
pread64(7, "\335\0\0\0\10\0\0\0\3\4\0\0\0\0\0\0\360z\346\0\0\0\0\0\360j\346\0\0\0\0\0"..., 64, 23576832) = 64
pread64(7, "\343\0\0\0\16\0\0\0\3\0\0\0\0\0\0\0\360z\346\0\0\0\0\0\360j\346\0\0\0\0\0"..., 64, 23576896) = 64
pread64(7, "\357\0\0\0\17\0\0\0\3\0\0\0\0\0\0\0\370z\346\0\0\0\0\0\370j\346\0\0\0\0\0"..., 64, 23576960) = 64
pread64(7, "\373\0\0\0\1\0\0\0\3\0\0\0\0\0\0\0\0{\346\0\0\0\0\0\0k\346\0\0\0\0\0"..., 64, 23577024) = 64
pread64(7, "\10\1\0\0\6\0\0\0\3\0\0\0\0\0\0\0000,b\1\0\0\0\0000\34b\1\0\0\0\0"..., 64, 23577088) = 64
pread64(7, "\254\0\0\0\1\0\0\0\3\0\0\0\0\0\0\0 .b\1\0\0\0\0 \36b\1\0\0\0\0"..., 64, 23577152) = 64
pread64(7, "\21\1\0\0\1\0\0\0\3\0\0\0\0\0\0\0\0000b\1\0\0\0\0\0 b\1\0\0\0\0"..., 64, 23577216) = 64
pread64(7, "\27\1\0\0\1\0\0\0\3\0\0\0\0\0\0\0\320\236c\1\0\0\0\0\320\216c\1\0\0\0\0"..., 64, 23577280) = 64
pread64(7, "%\1\0\0\1\0\0\0\3\0\0\0\0\0\0\0\340\247c\1\0\0\0\0\340\227c\1\0\0\0\0"..., 64, 23577344) = 64
pread64(7, "0\1\0\0\10\0\0\0\3\0\0\0\0\0\0\0@\312g\1\0\0\0\08\272g\1\0\0\0\0"..., 64, 23577408) = 64
pread64(7, "5\1\0\0\10\0\0\0\3\0\0\0\0\0\0\0\340\36k\1\0\0\0\08\272g\1\0\0\0\0"..., 64, 23577472) = 64
pread64(7, "?\1\0\0\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\08\272g\1\0\0\0\0"..., 64, 23577536) = 64
pread64(7, "\1\0\0\0\3\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0l\272g\1\0\0\0\0"..., 64, 23577600) = 64
pread64(7, "\0.shstrtab\0.interp\0.note.gnu.pro"..., 334, 23575148) = 334
pread64(7, "\4\0\0\0\20\0\0\0\5\0\0\0", 12, 880) = 12
pread64(7, "\4\0\0\0\24\0\0\0\3\0\0\0", 12, 912) = 12
pread64(7, "GNU\0", 4, 924)             = 4
pread64(7, "\375\211|\237\371\351\220\225\250Y\234a\257\373SG\0316\253A", 20, 928) = 20
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/bin/snap", 128) = 13
read(7, "25 31 0:23 / /sys rw,nosuid,node"..., 4096) = 2481
read(7, "", 4096)                       = 0
read(7, "# /etc/fstab: static file system"..., 4096) = 427
read(7, "", 3669)                       = 0
read(7, "25 31 0:23 / /sys rw,nosuid,node"..., 4096) = 2481
read(7, "", 4096)                       = 0
read(7, "kill_process kill_thread trap er"..., 512) = 63
read(7, "", 449)                        = 0
read(12, "", 8)                         = 0
read(7, "{\"version\":11,\"build-id\":\"fd897c"..., 765) = 764
read(7, "", 1)                          = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/bin/snap", 128) = 13
read(7, "", 512)                        = 0
readlinkat(AT_FDCWD, "/snap/zig/current", "11625", 128) = 5
read(8, "name: zig\ntitle: Zig\nversion: 0."..., 512) = 313
read(8, "", 199)                        = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/bin/snap", 128) = 13
read(8, "{\"sequence\":[{\"name\":\"zig\",\"snap"..., 1555) = 1554
read(8, "", 1)                          = 0
read(8, "retract"..., 4096) = 510
read(8, "", 4096)                       = 0
read(8, "root:x:0:0:root:/root:/bin/bash\n"..., 4096) = 2673
readlinkat(AT_FDCWD, "/root/snap/zig/current", "11625", 128) = 5
read(8, "25 31 0:23 / /sys rw,nosuid,node"..., 4096) = 2481
read(8, "", 4096)                       = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/bin/snap", 128) = 13
read(8, "retract"..., 4096) = 44
read(8, "REJECTED EXTERNAL\r\n", 4096)  = 19
read(8, "retract"..., 4096) = 37
read(8, "AGREE_UNIX_FD\r\n", 4096)      = 15
read(9, "retract"..., 512) = 37
read(9, "", 475)                        = 0
read(9, "retract"..., 4096) = 109
read(3, "retract"..., 832) = 832
read(3, "retract"..., 832) = 832
pread64(3, "retract"..., 784, 64) = 784
pread64(3, "retract"..., 48, 848) = 48
pread64(3, "retract"..., 68, 896) = 68
pread64(3, "retract"..., 784, 64) = 784
read(4, "KFUwomIYp2iRYApP8PsFQ5pVNzq0KUNh"..., 254) = 52
read(4, "Y\n", 2)                       = 2
read(4, "sysfs /sys sysfs rw,nosuid,nodev"..., 1024) = 1024
read(4, "/usr/lib/snapd/snap-confine (enf"..., 128) = 38
read(4, "", 90)                         = 0
read(4, "SC\1\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 128
readlink("/proc/self/fd/3", "/root", 4096) = 5
read(3, "2097152\n", 20)                = 8
read(3, "PRETTY_NAME=\"Ubuntu 22.04.5 LTS\""..., 4096) = 386
read(3, "", 3710)                       = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/lib/snapd/snap-exec", 128) = 24
read(7, "\336\22\4\225", 4)             = 4
read(7, "\0\0\0\0\"\0\0\0\34\0\0\0,\1\0\0/\0\0\0\2\0\0\0\0\0\0\370\2\0\0", 32) = 32
read(7, "\0\0\0\0\370\2\0\0", 8)        = 8
read(7, "\337\1\0\0\225\26\0\0", 8)     = 8
read(7, "Project-Id-Version: snapd\nReport"..., 479) = 479
read(7, "K\1\0\0\371\2\0\0", 8)         = 8
read(7, "I\1\0\0u\30\0\0", 8)           = 8
read(7, "\nThe ack command tries to add an"..., 331) = 331
read(7, "\nThe ack command tries to add an"..., 329) = 329
read(7, "^\1\0\0E\4\0\0", 8)            = 8
read(7, "^\1\0\0\277\31\0\0", 8)        = 8
read(7, "\nThe console-conf-start command "..., 350) = 350
read(7, "\nThe console-conf-start command "..., 350) = 350
read(7, "\254\1\0\0\244\5\0\0", 8)      = 8
read(7, "\255\1\0\0\36\33\0\0", 8)      = 8
read(7, "\nThe find command queries the st"..., 428) = 428
read(7, "\nThe find command queries the st"..., 429) = 429
read(7, "\314\0\0\0Q\7\0\0", 8)         = 8
read(7, "\315\0\0\0\314\34\0\0", 8)     = 8
read(7, "\nThe list command displays a sum"..., 204) = 204
read(7, "\nThe list command displays a sum"..., 205) = 205
read(7, "9\2\0\0\36\10\0\0", 8)         = 8
read(7, "B\2\0\0\232\35\0\0", 8)        = 8
read(7, "\nThe publisher of snap %q has in"..., 569) = 569
read(7, "\nThe publisher of snap %q has in"..., 578) = 578
read(7, "\322\1\0\0X\n\0\0", 8)         = 8
read(7, "\323\1\0\0\335\37\0\0", 8)     = 8
read(7, "\nThe reboot command can used fro"..., 466) = 466
read(7, "\nThe reboot command can used fro"..., 467) = 467
read(7, "\254\1\0\0+\f\0\0", 8)         = 8
read(7, "\255\1\0\0\261!\0\0", 8)       = 8
read(7, "\nThe reboot command reboots the "..., 428) = 428
read(7, "\nThe reboot command reboots the "..., 429) = 429
read(7, "\352\1\0\0\330\r\0\0", 8)      = 8
read(7, "\354\1\0\0_#\0\0", 8)          = 8
read(7, "\nThe remodel command changes the"..., 490) = 490
read(7, "\nThe remodel command changes the"..., 492) = 492
read(7, "&\1\0\0\303\17\0\0", 8)        = 8
read(7, "'\1\0\0L%\0\0", 8)             = 8
read(7, "\nThis revision of snap %q was pu"..., 294) = 294
read(7, "\nThis revision of snap %q was pu"..., 295) = 295
read(7, "\"\0\0\0\352\20\0\0", 8)       = 8
read(7, "!\0\0\0t&\0\0", 8)             = 8
read(7, "Allow snap %q to change %s to %q"..., 34) = 34
read(7, "Allow snap %q to change %s to %q"..., 33) = 33
read(7, "&\0\0\0\r\21\0\0", 8)          = 8
read(7, "'\0\0\0\226&\0\0", 8)          = 8
read(7, "An email of a user on login.ubun"..., 38) = 38
read(7, "An e-mail of a user on login.ubu"..., 39) = 39
read(7, "\0\0\0004\21\0\0", 8)         = 8
read(7, "\0\0\0\276&\0\0", 8)          = 8
read(7, "Authorization is required to aut"..., 60) = 60
read(7, "Authorisation is required to aut"..., 60) = 60
read(7, ")\0\0\0q\21\0\0", 8)           = 8
read(7, "*\0\0\0\373&\0\0", 8)          = 8
read(7, "Control the reboot behavior of t"..., 41) = 41
read(7, "Control the reboot behaviour of "..., 42) = 42
read(7, "\17\0\0\0\233\21\0\0", 8)      = 8
read(7, "\20\0\0\0&'\0\0", 8)           = 8
read(7, "Email address: ", 15)          = 15
read(7, "E-mail address: ", 16)         = 16
read(7, ",\0\0\0\253\21\0\0", 8)        = 8
read(7, ",\0\0\0007'\0\0", 8)           = 8
read(7, "Image customizations specified a"..., 44) = 44
read(7, "Image customisations specified a"..., 44) = 44
read(7, "\21\0\0\0\330\21\0\0", 8)      = 8
read(7, "\21\0\0\0d'\0\0", 8)           = 8
read(7, "Initialize device", 17)        = 17
read(7, "Initialise device", 17)        = 17
read(7, "\25\0\0\0\352\21\0\0", 8)      = 8
read(7, "\31\0\0\0v'\0\0", 8)           = 8
read(7, "Name of key to delete", 21)    = 21
read(7, "Name of key to be deleted", 25) = 25
read(7, "#\0\0\0\0\22\0\0", 8)          = 8
read(7, "%\0\0\0\220'\0\0", 8)          = 8
read(7, "Perform factory reset of the sys"..., 35) = 35
read(7, "Perform a factory reset of the s"..., 37) = 37
read(7, "a\0\0\0$\22\0\0", 8)           = 8
read(7, "f\0\0\0\266'\0\0", 8)          = 8
read(7, "Please be mindful pre-release ch"..., 97) = 97
read(7, "Please be mindful that pre-relea"..., 102) = 102
read(7, "_\0\0\0\206\22\0\0", 8)        = 8
read(7, "_\0\0\0\35(\0\0", 8)           = 8
read(7, "Please re-enter your Ubuntu One "..., 95) = 95
read(7, "Please re-enter your Ubuntu One "..., 95) = 95
read(7, "\32\0\0\0\346\22\0\0", 8)      = 8
read(7, "\33\0\0\0}(\0\0", 8)           = 8
read(7, "Print the version and exit", 26) = 26
read(7, "Print the version, and exit", 27) = 27
read(7, "\221\0\0\0\1\23\0\0", 8)       = 8
read(7, "\221\0\0\0\231(\0\0", 8)       = 8
read(7, "Run the command under strace (us"..., 145) = 145
read(7, "Run the command under strace (us"..., 145) = 145
read(7, "\26\1\0\0\223\23\0\0", 8)      = 8
read(7, "\27\1\0\0+)\0\0", 8)           = 8
read(7, "Select last change of given type"..., 278) = 278
read(7, "Select last change of given type"..., 279) = 279
read(7, "4\0\0\0\252\24\0\0", 8)        = 8
read(7, "6\0\0\0C*\0\0", 8)             = 8
read(7, "Set id of snapshot to delete (se"..., 52) = 52
read(7, "Set ID of snapshot to delete (se"..., 54) = 54
read(7, "\34\0\0\0\337\24\0\0", 8)      = 8
read(7, "\34\0\0\0z*\0\0", 8)           = 8
read(7, "Set id of snapshot to export", 28) = 28
read(7, "Set ID of snapshot to export", 28) = 28
read(7, "5\0\0\0\374\24\0\0", 8)        = 8
read(7, "7\0\0\0\227*\0\0", 8)          = 8
read(7, "Set id of snapshot to restore (s"..., 53) = 53
read(7, "Set ID of snapshot to restore (s"..., 55) = 55
read(7, "4\0\0\0002\25\0\0", 8)         = 8
read(7, "6\0\0\0\317*\0\0", 8)          = 8
read(7, "Set id of snapshot to verify (se"..., 52) = 52
read(7, "Set ID of snapshot to verify (se"..., 54) = 54
read(7, "&\0\0\0g\25\0\0", 8)           = 8
read(7, "'\0\0\0\6+\0\0", 8)            = 8
read(7, "The login.ubuntu.com email to lo"..., 38) = 38
read(7, "The login.ubuntu.com e-mail to l"..., 39) = 39
read(7, "C\0\0\0\216\25\0\0", 8)        = 8
read(7, "E\0\0\0.+\0\0", 8)             = 8
read(7, "This dialog will close automatic"..., 67) = 67
read(7, "This dialogue will close automat"..., 69) = 69
read(7, "3\0\0\0\322\25\0\0", 8)        = 8
read(7, "4\0\0\0t+\0\0", 8)             = 8
read(7, "Use a little bit of color to hig"..., 51) = 51
read(7, "Use a little bit of colour to hi"..., 52) = 52
read(7, "\6\0\0\0\6\26\0\0", 8)         = 8
read(7, "\7\0\0\0\251+\0\0", 8)         = 8
read(7, "email:", 6)                    = 6
read(7, "e-mail:", 7)                   = 7
read(7, "f\0\0\0\r\26\0\0", 8)          = 8
read(7, "h\0\0\0\261+\0\0", 8)          = 8
read(7, "invalid argument for snapshot se"..., 102) = 102
read(7, "invalid argument for snapshot se"..., 104) = 104
read(7, " \0\0\0t\26\0\0", 8)           = 8
read(7, " \0\0\0\32,\0\0", 8)           = 8
read(7, "snap %q has no updates available", 32) = 32
read(7, "snap %q has no available updates", 32) = 32
read(7, "BOOT_IMAGE=/boot/vmlinuz-5.15.0-"..., 512) = 153
read(7, "", 359)                        = 0
read(7, "name: zig\ntitle: Zig\nversion: 0."..., 512) = 313
read(7, "", 199)                        = 0

163 read syscallls. Why do you need this? What are these two:

read(7, "Set id of snapshot to export", 28) = 28
read(7, "Set ID of snapshot to export", 28) = 28

Why is it id in one and ID in the other one? And I shit you not I didn't duplicate any of the syscalls. This is what snap does every time you run zig ( and most likely every other app you install using snap. )

Write syscall

write(8, "AUTH\r\n", 6)                 = 6
write(8, "AUTH EXTERNAL 30\r\n", 18)    = 18
write(8, "NEGOTIATE_UNIX_FD\r\n", 19)   = 19
write(8, "BEGIN\r\n", 7)                = 7
write(8, "l\1\0\1\0\0\0\0\1\0\0\0m\0\0\0\1\1o\0\25\0\0\0/org/fre"..., 128) = 128
write(8, "l\1\0\1S\0\0\0\2\0\0\0~\0\0\0\6\1s\0\24\0\0\0org.free"..., 227) = 227
write(8, "l\1\0\1p\0\0\0\3\0\0\0\266\0\0\0\1\1o\0\31\0\0\0/org/fre"..., 312) = 312
write(6, "\0", 1)                       = 1
write(8, "l\1\0\1S\0\0\0\4\0\0\0|\0\0\0\2\1s\0\24\0\0\0org.free"..., 227) = 227
write(4, "exec snap.zig.zig", 17)       = 17
write(2, "info: ", 6)                   = 6
write(2, "Usage: zig [command] [options]\n\n"..., 1598) = 1598
write(2, "\n", 1)                       = 1
write(2, "error: expected command argument"..., 33) = 33

Ok this is not that bad. Wea re starting to see first syscalls zig makes. In fact last 4 write syscalles are made my zig. Rest are not. And I shit you not. None of the other syscalls I mentioned are not produced by zig ( Execept maybe execve ( depends how you count it ) )

Socket

There are also socket and related syscall. But only AF_UNIX so I guess that is not too bad ( And only 3 times )

Tally

## zig snap zig
write syscalls 4 14
read syscalls 0 163
open syscalls 0 68
execve syscalls 1 4
socket syscalls 0 3
total syscalls 83 1697 (I shit you not..)

hyperfine

Only running zig without arguments

# hyperfine --warmup 3 -i "zig"
Benchmark 1: zig
  Time (mean σ):      58.4 ms  24.2 ms    [User: 25.1 ms, System: 24.0 ms]
  Range (min max):    26.8 ms  93.7 ms    38 runs

  Warning: Ignoring non-zero exit code.
# hyperfine --warmup 3 -i "/snap/zig/current/zig"
Benchmark 1: /snap/zig/current/zig
  Time (mean σ):       8.8 ms  15.0 ms    [User: 2.8 ms, System: 4.7 ms]
  Range (min max):     3.2 ms  61.8 ms    738 runs

  Warning: Command took less than 5 ms to complete. Results might be inaccurate.
  Warning: Ignoring non-zero exit code.
  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet PC without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Running zig such that it compiles a .c file

test.c

#include "stdio.h"

int main(void) {
    printf("Hello \n");
    return 0;
}
# hyperfine --warmup 3 -i "zig cc test.c"
Benchmark 1: zig cc test.c
  Time (mean σ):      92.8 ms  12.2 ms    [User: 35.7 ms, System: 46.9 ms]
  Range (min max):    48.6 ms 106.7 ms    32 runs
# hyperfine --warmup 3 -i "/snap/zig/current/zig cc test.c"
Benchmark 1: /snap/zig/current/zig cc test.c
  Time (mean σ):      39.8 ms  16.4 ms    [User: 17.1 ms, System: 19.9 ms]
  Range (min max):    23.9 ms  70.3 ms    117 runs