RFR: 8238161: use os::fopen in HS code where possible
Baesken, Matthias
matthias.baesken at sap.com
Tue Feb 4 11:17:48 UTC 2020
>
> On 3/02/2020 10:35 pm, Baesken, Matthias wrote:
> > Hi David, from what I understand it should behave in the same way it does
> when a file descriptor to a "normal" file is opened .
> > At least checking for the FD_CLOEXEC flag for such an fd works as
> expected
> >
> > /* check that O_CLOEXEC works */
> > int fd = open64("/proc/cpuinfo", O_CLOEXEC, 0444);
> > int flags;
> >
> > flags = ::fcntl(fd, F_GETFD);
> > if (flags != -1) {
> > if ((flags & FD_CLOEXEC) != 0) {
> > printf("setting O_CLOEXEC with open seems to work.\n");
> > } else {
> > printf("PROBLEM setting O_CLOEXEC with open !\n");
> > }
> > }
> >
> >
> > ... outputs : "setting O_CLOEXEC with open seems to work."
>
> I expect it to be applicable but does it actually do anything such that
> it is necessary to go and make these changes for /proc filesystem
> usages? This is probably harmless but it also seems somewhat unnecessary
> to do.
>
Hi David , probably for my small example (or generally for /proc/cpuinfo) it would not be necessary.
Regarding other fds dealing with /proc like
cgroupSubsystem_linux.cpp
66 cgroups = fopen("/proc/cgroups", "r");
121 cgroup = fopen("/proc/self/cgroup", "r");
170 mntinfo = fopen("/proc/self/mountinfo", "r");
224 mntinfo = fopen("/proc/self/mountinfo", "r");
Maybe the cgroup/container folks could comment how important/unimportant it is to have the close-on-exec set on the fds in this case?
Best regards, Matthias
More information about the hotspot-dev
mailing list