From 08fe0bdbdb1a3e10bc7e2b07b317e271ce99049a Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Sun, 27 Oct 2013 12:09:37 +0000 Subject: [PATCH] On Linux, skip virtual ttys that have no parent device. --- serialport.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/serialport.c b/serialport.c index 0895048..a8f410e 100644 --- a/serialport.c +++ b/serialport.c @@ -176,7 +176,7 @@ out_release: struct udev_list_entry *ud_list; struct udev_list_entry *ud_entry; const char *path; - struct udev_device *ud_dev; + struct udev_device *ud_dev, *ud_parent; const char *name; ud = udev_new(); @@ -190,6 +190,13 @@ out_release: { path = udev_list_entry_get_name(ud_entry); ud_dev = udev_device_new_from_syspath(ud, path); + /* If there is no parent device, this is a virtual tty. */ + ud_parent = udev_device_get_parent(ud_dev); + if (ud_parent == NULL) + { + udev_device_unref(ud_dev); + continue; + } name = udev_device_get_devnode(ud_dev); list = sp_list_append(list, (void *)name, strlen(name) + 1); udev_device_unref(ud_dev);