r/C_Programming • u/Read-Documentation-7 • Jun 07 '26
Why Processes?
Hello. I was wondering what are the benefits of using processes over threads. I understand the differences between the two, but I am having trouble trying to understand when would be the best use case to implement them. Can someone give me some advice for when processes should be used? Thanks.
38
Upvotes
View all comments
Show parent comment
2
u/protestor Jun 08 '26
indeed processes can share memory if someone wants, and share many other things like file descriptors (which can be sent to another process through an unix socket), so really processes give some degree of isolation by default but can still support sharing when needed
and that's why you can for example run some untrusted/unreviewed code in a process with minimal privileges, but still have it give their results back using shared memory (so, no expensive IPC - as little overhead as threads and the required atomic operations to synchronize between sender and receiver). that's what browsers do when they need to run code with high probability of exploits. you can't do this with threads
so something like https://github.com/google/sandboxed-api needs to use processes