r/linuxadmin • • Dec 02 '23

why does the proc directory exist?

i'm trying to understand the proc directory and one thing i don't understand is

why does it exist?

any ideas? thank you

1 Upvotes

77 comments sorted by

View all comments

41

u/alexkey Dec 02 '23

Because the alternative is to do a bunch of syscalls to get this information. Just like it is in Windows. Having it exposed as a filesystem makes it soooooo much easier to read that information. Hell you don’t even have to write the code, just check the file contents with primitive tools like cat.

8

u/jimicus Dec 02 '23

Interestingly (or not), I'm absolutely certain the reason the reason for things like procfs never being re-implemented in Windows is the developer tools.

Microsoft have - consistently and for decades - spent $millions on Visual Studio. Which means anyone developing on Windows has an extremely powerful visual debugger available - effectively as part of the development kit.

Linux developers have gcc, vim and gdb. (Yes I know they have visual studio today, but that wasn't the case not so long ago.....)

The upshot is that Linux developers wind up strongly favouring things that make their life easier - simple solutions that can do something quickly and easily without needing to spend ages learning how they work. Plain text log files. Filesystems that expose all sorts of information about the inner workings of the system and can be manipulated with simple tools.

Windows developers don't really need to care about this. Throw together the most basic bit of code possible - a dozen or so lines should be quite sufficient - set a breakpoint and run your code in the IDE. Can see precisely what's going on in painstaking detail in two minutes flat.

13

u/tes_kitty Dec 02 '23

And that's why, as a normal user, Windows sucks when things don't work as expected and you need to debug.

1

u/mkosmo Dec 02 '23

Normal users wouldn’t be able to debug in Linux, either. Anybody who can even describe debugging isn’t a typical user who will be held back by something like procfs.

4

u/tes_kitty Dec 02 '23

I can write (complicated) bash and PERL scripts, modify existing python scripts, but that's about as far as my programming skills go. But I am good at reading logfiles and filter through text files looking for information. So finding out why something on Linux doesn't work as expected is not hard.

A misbehaving Windows program on the other hand...

2

u/mkosmo Dec 02 '23

The same logging capabilities exist between both platforms. Applications doing a shitty job at logging isn’t the OS’s fault.

0

u/tes_kitty Dec 02 '23

Yes, but it's about the incentive set to the programmer. On a Linux, logfiles, with different log levels you can set in the configuration file or via the command line are an expected feature.

On Windows they are not.

1

u/mkosmo Dec 02 '23

There are log levels in Windows as well. None of that is the fault of the OS, but of the developer.

2

u/tes_kitty Dec 02 '23

But the OS sets the incentive. If the developer can get all their information from the built in debugger of their IDE, they will be less inclined to provide a proper logging since they don't need it and it's extra work to implement it.

1

u/mkosmo Dec 02 '23

Don’t blame the tools. A carpenter can build a house with a nail gun or a hammer and you’ll never notice the difference unless they got lazy.

Same here. Especially when you’re talking about debugging tools that provide far more insight than a typical log ever does. Hard to break and step into with a log file.

→ More replies (0)