Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
if (ret == 0 && event->event->instrumentation == LTTNG_KERNEL_SYSCALL) {
DBG2("Kernel event syscall creation success");
+ /*
+ * We use fd == -1 to ensure that we never trigger a close of fd
+ * 0.
+ */
+ event->fd = -1;
goto add_list;
}
*/
void trace_kernel_destroy_event(struct ltt_kernel_event *event)
{
- DBG("[trace] Closing event fd %d", event->fd);
- /* Close kernel fd */
- close(event->fd);
+ if (event->fd >= 0) {
+ DBG("[trace] Closing event fd %d", event->fd);
+ /* Close kernel fd */
+ close(event->fd);
+ } else {
+ DBG("[trace] Tearing down event (no associated fd)");
+ }
/* Remove from event list */
cds_list_del(&event->list);