Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kamil Konieczny <kamil.konieczny@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Sai Gowtham Ch <sai.gowtham.ch@intel.com>,
	Chris Wilson <chris.p.wilson@intel.com>
Subject: [igt-dev] [PATCH i-g-t] lib: Don't assert if fd path is unreachable
Date: Mon,  5 Jun 2023 20:17:53 +0200	[thread overview]
Message-ID: <20230605181753.40607-1-kamil.konieczny@linux.intel.com> (raw)

From: Chris Wilson <chris.p.wilson@intel.com>

Processes come and go, access to the /proc/$tid/fd/ is unreliable. Don't
assert when dumping the debug info of what the process has open if that
process is already destroyed.

Cc: Sai Gowtham Ch <sai.gowtham.ch@intel.com>
Signed-off-by: Chris Wilson <chris.p.wilson@intel.com>
Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
 lib/igt_aux.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index f2b9671e3..386e25783 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -1451,16 +1451,18 @@ igt_show_stat(const pid_t tid, const char *cmd, int *state, const char *fn)
 static void
 __igt_lsof_fds(const pid_t tid, const char *cmd, int *state, char *proc_path, const char *dir)
 {
+	/* default fds or kernel threads */
+	static const char *default_fds[] = { "/dev/pts", "/dev/null" };
 	struct dirent *d;
 	struct stat st;
 	char path[PATH_MAX];
 	char *fd_lnk;
+	DIR *dp;
 
-	/* default fds or kernel threads */
-	const char *default_fds[] = { "/dev/pts", "/dev/null" };
+	dp = opendir(proc_path);
+	if (!dp)
+		return;
 
-	DIR *dp = opendir(proc_path);
-	igt_assert(dp);
 again:
 	while ((d = readdir(dp))) {
 		char *copy_fd_lnk;
@@ -1780,7 +1782,8 @@ __igt_lsof_audio_and_kill_proc(const pid_t tid, const char *cmd, const uid_t eui
 	dp = opendir(proc_path);
 	if (!dp && errno == ENOENT)
 		return 0;
-	igt_assert(dp);
+	if (!dp)
+		return 1;
 
 	while ((d = readdir(dp))) {
 		if (*d->d_name == '.')
-- 
2.39.2

             reply	other threads:[~2023-06-05 18:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 18:17 Kamil Konieczny [this message]
2023-06-05 20:53 ` [igt-dev] ✓ Fi.CI.BAT: success for lib: Don't assert if fd path is unreachable Patchwork
2023-06-06  3:55 ` [igt-dev] [PATCH i-g-t] " Ch, Sai Gowtham
2023-06-06 21:04 ` [igt-dev] ✓ Fi.CI.IGT: success for " Patchwork
2023-06-07  6:31 ` [igt-dev] [PATCH i-g-t] " Zbigniew Kempczyński

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230605181753.40607-1-kamil.konieczny@linux.intel.com \
    --to=kamil.konieczny@linux.intel.com \
    --cc=chris.p.wilson@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=sai.gowtham.ch@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox