[PATCH v1 2/2] strace.c: move termination code to a separate function

Dmitry V. Levin ldv at altlinux.org
Sun Jun 4 23:10:25 UTC 2017


On Sun, Jun 04, 2017 at 02:00:06AM +0300, Victor Krapivensky wrote:
> This will be needed for the pull-style API.
> 
> * strace.c (terminate): New function.
> (main): Use it.

This one is easy. :)

> ---
>  strace.c | 30 ++++++++++++++++++------------
>  1 file changed, 18 insertions(+), 12 deletions(-)
> 
> diff --git a/strace.c b/strace.c
> index 55c6fe76..2657bcf7 100644
> --- a/strace.c
> +++ b/strace.c
> @@ -2593,18 +2593,9 @@ dispatch_event(enum trace_event ret, int *pstatus, siginfo_t *si)
>  extern void __gcov_flush();
>  #endif
>  
> -int
> -main(int argc, char *argv[])
> +static void
> +terminate(void)
>  {
> -	init(argc, argv);
> -
> -	exit_code = !nprocs;
> -
> -	int status;
> -	siginfo_t si;
> -	while (dispatch_event(next_event(&status, &si), &status, &si))
> -		;
> -
>  	cleanup();
>  	fflush(NULL);
>  	if (shared_log != stderr)
> @@ -2639,6 +2630,21 @@ main(int argc, char *argv[])
>  		   Exit with 128 + signo then.  */
>  		exit_code += 128;
>  	}
> +	exit(exit_code);
> +}
> +
> +int
> +main(int argc, char *argv[])
> +{
> +	init(argc, argv);
> +
> +	exit_code = !nprocs;
> +
> +	int status;
> +	siginfo_t si;
> +	while (dispatch_event(next_event(&status, &si), &status, &si))
> +		;
>  
> -	return exit_code;
> +	terminate();
> +	return 0; /* stub */

Try ATTRIBUTE_NORETURN instead.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170605/bb7560da/attachment.bin>


More information about the Strace-devel mailing list