summaryrefslogtreecommitdiffstats
path: root/rfcomm
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2004-05-09 09:35:52 +0000
committerMarcel Holtmann <marcel@holtmann.org>2004-05-09 09:35:52 +0000
commitc337593d343e7320332557ba9137561eefabf22e (patch)
treeb839587cf08c66b4df522929e057fcc00d79715c /rfcomm
parentae9e56a7b15b4ddd014b30229ad4e4bcafe836e3 (diff)
Fix TTY creation problem for listen commandutils-2.7
Diffstat (limited to 'rfcomm')
-rw-r--r--rfcomm/main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/rfcomm/main.c b/rfcomm/main.c
index dbb74869..3a7fe0a5 100644
--- a/rfcomm/main.c
+++ b/rfcomm/main.c
@@ -442,14 +442,21 @@ static void cmd_listen(int ctl, int dev, bdaddr_t *bdaddr, int argc, char **argv
}
snprintf(devname, MAXPATHLEN - 1, "/dev/rfcomm%d", dev);
- if ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0) {
+ while ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0) {
snprintf(devname, MAXPATHLEN - 1, "/dev/bluetooth/rfcomm/%d", dev);
- while ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0) {
+ if ((fd = open(devname, O_RDONLY | O_NOCTTY)) < 0) {
if (try--) {
+ snprintf(devname, MAXPATHLEN - 1, "/dev/rfcomm%d", dev);
sleep(1);
continue;
}
perror("Can't open RFCOMM device");
+
+ memset(&req, 0, sizeof(req));
+ req.dev_id = dev;
+ req.flags = (1 << RFCOMM_HANGUP_NOW);
+ ioctl(ctl, RFCOMMRELEASEDEV, &req);
+
close(sk);
return;
}