X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fuserspace-probe.c;h=e85c3c56fc67eea6163b5442694a1855332892ad;hb=166fc58650170d8213cd7d43c68d9a6601336dd0;hp=a15e5b7e42480fd50484c039a1722791536f313f;hpb=c9681eeb9b28e32f5ee77aea875d87889fdfd086;p=lttng-tools.git diff --git a/src/common/userspace-probe.c b/src/common/userspace-probe.c index a15e5b7e4..e85c3c56f 100644 --- a/src/common/userspace-probe.c +++ b/src/common/userspace-probe.c @@ -413,17 +413,20 @@ lttng_userspace_probe_location_function_copy( goto error; } - /* Duplicate the binary fd */ + /* + * Duplicate the binary fd if possible. The binary fd can be -1 on + * listing + */ fd = lttng_userspace_probe_location_function_get_binary_fd(location); - if (fd == -1) { - ERR("Error getting file descriptor to binary"); - goto error; - } - - new_fd = dup(fd); - if (new_fd == -1) { - PERROR("Error duplicating file descriptor to binary"); - goto error; + if (fd > -1) { + new_fd = dup(fd); + if (new_fd == -1) { + PERROR("Error duplicating file descriptor to binary"); + goto error; + } + } else { + /* The original fd is not set. */ + new_fd = -1; } /* @@ -509,15 +512,15 @@ lttng_userspace_probe_location_tracepoint_copy( /* Duplicate the binary fd */ fd = lttng_userspace_probe_location_tracepoint_get_binary_fd(location); - if (fd == -1) { - ERR("Error getting file descriptor to binary"); - goto error; - } - - new_fd = dup(fd); - if (new_fd == -1) { - PERROR("Error duplicating file descriptor to binary"); - goto error; + if (fd > -1) { + new_fd = dup(fd); + if (new_fd == -1) { + PERROR("Error duplicating file descriptor to binary"); + goto error; + } + } else { + /* The original fd is not set. */ + new_fd = -1; } /*