public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/6] lib/tst_run_cmd_*(): Search for program in $PATH
Date: Mon, 30 Mar 2020 13:40:41 +0200	[thread overview]
Message-ID: <20200330114041.GF9845@yuki.lan> (raw)
In-Reply-To: <20200327213924.18816-5-pvorel@suse.cz>

Hi!
> +	/* exit with TCONF if program is not in path */
> +	TST_RUN_CMD_CHECK_CMD = 2,

Shouldn't be this rather called TST_CMD_TCONF_ON_MISSING?

>  };
>  
>  /*
> diff --git a/lib/tst_run_cmd.c b/lib/tst_run_cmd.c
> index 3536ec494..0494c6083 100644
> --- a/lib/tst_run_cmd.c
> +++ b/lib/tst_run_cmd.c
> @@ -56,6 +56,17 @@ int tst_run_cmd_fds_(void (cleanup_fn)(void),
>  	 */
>  	void *old_handler = signal(SIGCHLD, SIG_DFL);
>  
> +	const char *cmd;
> +	char path[PATH_MAX];
> +
> +	if (tst_get_path(argv[0], path, sizeof(path))) {
> +		if (flags & TST_RUN_CMD_CHECK_CMD)
> +			tst_brkm(TCONF, "Couldn't find '%s' in $PATH at %s:%d", argv[0],
> +				 __FILE__, __LINE__);
> +		else
> +			_exit(255);
> +	}
> +
>  	pid_t pid = vfork();
>  	if (pid == -1) {
>  		tst_brkm(TBROK | TERRNO, cleanup_fn, "vfork failed at %s:%d",
> @@ -74,10 +85,7 @@ int tst_run_cmd_fds_(void (cleanup_fn)(void),
>  			dup2(stderr_fd, STDERR_FILENO);
>  		}
>  
> -		if (execvp(argv[0], (char *const *)argv)) {
> -			if (errno == ENOENT)
> -				_exit(255);
> -		}
> +		execvp(argv[0], (char *const *)argv);
>  		_exit(254);
>  	}
>  
> -- 
> 2.25.1
> 

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2020-03-30 11:40 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 21:39 [LTP] [PATCH 0/6] C API: .needs_cmds and SAFE_RUN_CMD() Petr Vorel
2020-03-27 21:39 ` [LTP] [PATCH 1/6] lib: Implement .needs_cmds Petr Vorel
2020-03-30  6:13   ` Li Wang
2020-03-30  7:03     ` Petr Vorel
2020-03-30 11:31       ` Cyril Hrubis
2020-03-27 21:39 ` [LTP] [PATCH 2/6] Use .needs_cmds Petr Vorel
2020-03-30 11:31   ` Cyril Hrubis
2020-03-30 11:48     ` Petr Vorel
2020-03-30 11:57       ` Li Wang
2020-03-30 12:17         ` Petr Vorel
2020-03-30 12:37         ` Petr Vorel
2020-03-27 21:39 ` [LTP] [PATCH 3/6] lib/tst_run_cmd_*(): Turn int pass_exit_val into enum Petr Vorel
2020-03-30 11:38   ` Cyril Hrubis
2020-03-30 11:40     ` Petr Vorel
2020-03-27 21:39 ` [LTP] [PATCH 4/6] lib/tst_run_cmd_*(): Search for program in $PATH Petr Vorel
2020-03-30 11:40   ` Cyril Hrubis [this message]
2020-03-30 11:52     ` Petr Vorel
2020-03-30 11:53       ` Cyril Hrubis
2020-03-27 21:39 ` [LTP] [PATCH 5/6] lib: Implement SAFE_RUN_CMD() macro (new API only) Petr Vorel
2020-03-30  6:35   ` Li Wang
2020-03-30  8:44     ` Petr Vorel
2020-03-27 21:39 ` [LTP] [PATCH 6/6] Use SAFE_RUN_CMD() Petr Vorel
2020-03-28  2:41 ` [LTP] [PATCH 0/6] C API: .needs_cmds and SAFE_RUN_CMD() Xiao Yang
2020-03-28  3:42   ` Petr Vorel
2020-03-29  5:29     ` Xiao Yang
2020-03-30  4:39       ` Li Wang
2020-03-30  5:20         ` Xiao Yang
2020-03-30  7:12           ` Petr Vorel
2020-03-30  7:43             ` Xiao Yang
2020-03-30  4:24     ` Li Wang

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=20200330114041.GF9845@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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