Linux bluetooth development
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ 1/2] Add support for cancelling a LE Scan with Control-C
Date: Thu, 6 Oct 2011 18:49:47 +0300	[thread overview]
Message-ID: <20111006154947.GA10744@fusion.localdomain> (raw)
In-Reply-To: <1317912132-6644-1-git-send-email-vinicius.gomes@openbossa.org>

Hi Vinicius,

On Thu, Oct 06, 2011, Vinicius Costa Gomes wrote:
> ---
> +static void sigint_handler(int sig)
> +{
> +	int err;
> +
> +	setsockopt(signal_data.fd, SOL_HCI, HCI_FILTER, &signal_data.of, sizeof(signal_data.of));
> +
> +	err = hci_le_set_scan_enable(signal_data.fd, 0x00, 0x00, 1000);
> +	if (err < 0) {
> +		perror("Disable scan failed");
> +		exit(1);
> +	}
> +
> +	hci_close_dev(signal_data.fd);
> +
> +	exit(0);
> +}

To my understanding the general recommendation is to do as little as
possible within signal handlers. Would it therefore make more sense to
simply set a flag (indicating which signal was received) in the handler,
and then do the necessary cleanup within the original function by
handling EINTR there (presumably returned by the read system call)?

Johan

  parent reply	other threads:[~2011-10-06 15:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-06 14:42 [PATCH BlueZ 1/2] Add support for cancelling a LE Scan with Control-C Vinicius Costa Gomes
2011-10-06 14:42 ` [PATCH BlueZ 2/2] Add support for parsing the remote name during LE Scan Vinicius Costa Gomes
2011-10-11 11:47   ` Johan Hedberg
2011-10-13 16:41   ` [PATCH BlueZ] " Vinicius Costa Gomes
2011-10-13 21:39     ` Vinicius Costa Gomes
2011-10-14  8:01       ` Johan Hedberg
2011-10-14 11:34         ` Johan Hedberg
2011-10-06 15:49 ` Johan Hedberg [this message]
2011-10-06 16:22   ` [PATCH BlueZ 1/2] Add support for cancelling a LE Scan with Control-C Vinicius Costa Gomes
2011-10-06 18:03 ` [PATCH BlueZ] " Vinicius Costa Gomes
2011-10-07 20:27   ` Johan Hedberg

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=20111006154947.GA10744@fusion.localdomain \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=vinicius.gomes@openbossa.org \
    /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