[ltt-dev] [UST PATCH] Make tracectl destructor aware of fork status

David Goulet david.goulet at polymtl.ca
Tue Oct 26 08:20:52 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Acked-by: David Goulet <david.goulet at polymtl.ca>

On 10-10-25 06:59 AM, Nils Carlson wrote:
> This little patch checks to see whether we have used a fork
> wrapper to fork. If not we won't have a working UST in the process
> and can skip the destructor stage.
> 
> Signed-off-by: Nils Carlson <nils.carlson at ericsson.com>
> ---
>  libust/tracectl.c |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/libust/tracectl.c b/libust/tracectl.c
> index 3d09cc2..5f942cd 100644
> --- a/libust/tracectl.c
> +++ b/libust/tracectl.c
> @@ -50,6 +50,12 @@
>   */
>  s64 pidunique = -1LL;
>  
> +/* The process pid is used to detect a non-traceable fork
> + * and allow the non-traceable fork to be ignored
> + * by destructor sequences in libust
> + */
> +static pid_t processpid = 0;
> +
>  static struct ustcomm_header _receive_header;
>  static struct ustcomm_header *receive_header = &_receive_header;
>  static char receive_buffer[USTCOMM_BUFFER_SIZE];
> @@ -1201,6 +1207,7 @@ static void __attribute__((constructor)) init()
>  	 * pid, (before and after an exec).
>  	 */
>  	pidunique = make_pidunique();
> +	processpid = getpid();
>  
>  	DBG("Tracectl constructor");
>  
> @@ -1466,6 +1473,10 @@ static void stop_listener(void)
>  
>  static void __attribute__((destructor)) keepalive()
>  {
> +	if (processpid != getpid()) {
> +		return;
> +	}
> +
>  	if (trace_recording() && LOAD_SHARED(buffers_to_export)) {
>  		int total = 0;
>  		DBG("Keeping process alive for consumer daemon...");
> @@ -1516,6 +1527,9 @@ static void ust_fork(void)
>  	/* FIXME: technically, the locks could have been taken before the fork */
>  	DBG("ust: forking");
>  
> +	/* Get the pid of the new process */
> +	processpid = getpid();
> +
>  	/* break lock if necessary */
>  	ltt_unlock_traces();
>  

- -- 
David Goulet
LTTng project, DORSAL Lab.

1024D/16BD8563
BE3C 672B 9331 9796 291A  14C6 4AF7 C14B 16BD 8563
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkzGx6MACgkQSvfBSxa9hWO5wACfdopsgfbBPja3hYy+1yPX33+y
H6sAoN0mmOXAYZOfE3/74n1wOjMCBtip
=JPaI
-----END PGP SIGNATURE-----




More information about the lttng-dev mailing list