[LTP] [PATCH 1/3] syscalls/mmap05: Rewrite the test using new LTP API

Cyril Hrubis chrubis@suse.cz
Wed Aug 30 13:50:53 CEST 2023


Hi!
Pushed with two minor changes, thanks.

> +static void sig_handler(int sig)
>  {
> +	if (sig == SIGSEGV) {
> +		sig_flag = 1;
> +		siglongjmp(env, 1);
> +	} else
> +		tst_brk(TBROK, "Received an unexpected signal: %d", sig);

I've removed this else branch since tst_brk() unlike tst_res() is not
async-signal-safe since tst_brk() calls exit.

>  }
>  
>  static void setup(void)
>  {
> -	char *tst_buff;
> -
> -	tst_sig(NOFORK, sig_handler, cleanup);
> +	char *buf;
>  
> -	TEST_PAUSE;
> +	SAFE_SIGNAL(SIGSEGV, sig_handler);
>  
>  	page_sz = getpagesize();
> +	buf = SAFE_CALLOC(page_sz, sizeof(char));

And changed this to SAFE_MALLOC(page_sz); since sizeof(char) == 1 by
definition.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list