On Thu, 8 Apr 2021 07:25:20 +0300 Tzvetomir Stoyanov <tz.stoyanov@xxxxxxxxx> wrote: > > diff --git a/src/tracefs-instance.c b/src/tracefs-instance.c > > index bf2fabf..9f45624 100644 > > --- a/src/tracefs-instance.c > > +++ b/src/tracefs-instance.c > > @@ -44,6 +44,7 @@ static struct tracefs_instance *instance_alloc(const char *trace_dir, const char > > } > > > > instance->ftrace_filter_fd = -1; > > + instance->ftrace_notrace_fd = -1; > > These descriptors should be closed in tracefs_instance_free(), as part > of the instance cleanup. Good point. I'll add a patch on top of this one to close both of them. > > > > > return instance; > > > > diff --git a/src/tracefs-tools.c b/src/tracefs-tools.c > > index 21a9bd3..b41806b 100644 > > --- a/src/tracefs-tools.c > > +++ b/src/tracefs-tools.c > > @@ -21,10 +21,12 @@ > > > > #define TRACE_CTRL "tracing_on" > > #define TRACE_FILTER "set_ftrace_filter" > > +#define TRACE_NOTRACE "set_ftrace_notrace" > > #define TRACE_FILTER_LIST "available_filter_functions" > > > > /* File descriptor for Top level set_ftrace_filter */ > > static int ftrace_filter_fd = -1; > > +static int ftrace_notrace_fd = -1; > > static pthread_mutex_t filter_lock = PTHREAD_MUTEX_INITIALIZER; > > I'm wondering if we should free these global resources somehow. A > cleanup API for the whole library can be implemented using > __attribute__((destructor)), or some other way ? No need. The OS will close them for you when the application exits. All file descriptors that are opened will be closed by the OS. That said, we should probably add O_CLOEXEC in the open for them such that they don't stay open if the application does an exec() system call. -- Steve