Reading all of /proc/cpuinfo on mint linux fails

Is this a bug?
I found this working on reading a different file in /proc but this is a shorter example to demonstrate.

So this code doesn’t do what I expect (this is on mint linux with ‘odin version dev-2025-11-nightly’

package main

import "core:fmt"
import "core:os"

main :: proc() {
    file_contents, ok := os.read_entire_file("/proc/cpuinfo")
    if !ok do panic("Unable to read /proc/cpuinfo")

    fmt.println(file_contents)
}

It returns success but the contents is an empty slice of bytes. it works for normal files but fails for anything I’ve tested in /proc
I understand that files in /proc are not normal files, but I can’t imagine it’s intended that this returns success but doesn’t actually do what it ought to?

os is soon to be replaced by os2. I think I saw a post in these forums about Q1 of 2026. Most of the OS work is being done there I think. Try this below. It works for me. Add your own error checking as needed.

import "core:os/os2"
import "core:fmt"
file, file_err := os2.open("/proc/cpuinfo")
file_contents_allocator := context.allocator
file_contents, file_contents_err := os2.read_entire_file_from_file(file, file_contents_allocator)
defer os2.close(file)
defer delete(file_contents, file_contents_allocator)

fmt.printfln("%s", file_contents)

or the simpler version

file, file_err := os2.read_entire_file("/proc/cpuinfo", context.allocator)
defer delete(file)

fmt.printfln("%s", file)
1 Like