News for hackers. Stuff that matters.
Re:Understanding /proc by to3m on Wednesday October 05, 2016 @10:23AM (#12644036)
Even if you fix the pid reuse problem, you'll still have difficulties parsing things like /proc/PID/maps. Unless your pseudo-file consists of fixed-size records - and as I recall, /proc/PID/maps doesn't, as each line has a variable-width path in it - your best option is just to read the entire file in at once, and fingers crossed it ended up being atomic (Obviously the system can't block operations that affect the maps file...)

signalfd gets this bit right.

It didn't take much POSIX programming before I started to look at Windows in a whole new light...

Re:Understanding /proc by cyphar on Thursday October 06, 2016 @09:58AM (#12652460)
> signalfd gets this bit right.

I'd be careful saying that any API based around signals is "right". In general, signals are just horrible and I really wish that the UNIX history had played out differently.

Re:Understanding /proc by tcoppi on Wednesday October 05, 2016 @11:40AM (#12644785)
I agree that parsing /proc/pid/maps is a complete nightmare, but I'm pretty sure that the way pseudo-files on linux work, it is guaranteed the contents won't change out from under you while you are reading it.
Re:Understanding /proc by cyphar on Wednesday October 05, 2016 @08:48PM (#12649243)
Not all pseudo-files are like that. For example, /sys/fs/cgroup/.../cgroup.procs will only have consistent content if you read everything in a single page. Which is kinda dumb IMO.
Re:Understanding /proc by tcoppi on Thursday October 06, 2016 @08:36AM (#12651887)
Interesting... good to know.