[systemd-devel] [PATCH] systemd-bootchart: Prevent closing random file descriptors

Alexander Sverdlin alexander.sverdlin at gmail.com
Sun Mar 29 06:04:56 PDT 2015


Hello Daniel,

On 29/03/15 13:44, Daniel Mack wrote:
>> @@ -184,6 +185,7 @@ vmstat_next:
>> >           n = pread(schedstat, buf, sizeof(buf) - 1, 0);
>> >           if (n <= 0) {
>> >                   close(schedstat);
>> >+                schedstat = 0;
> Note that 0 is a valid file descriptor number. You should really rather
> reset the variables to -1 and check for '>= 0'. This applies to all
> hunks of this patch, which also needs a rebase onto the current git HEAD.

I believe, it was HEAD as of time of patch submission, but I can of course rebase it once again.
Regarding 0: everywhere in the program it relies on the fact that newly allocated memory is zeroed
and files are only opened if the corresponding file descriptor field of a structure is 0. So do you
propose to change the logic everywhere where the files are opened?

Alexander.


More information about the systemd-devel mailing list