struct modem_data {
char *device;
GIOChannel *channel;
+ guint watch;
GSList *callbacks;
GSList *commands;
char buf[1024];
tcflush(fd, TCIOFLUSH);
/* Switch TTY to raw mode */
+ memset(&ti, 0, sizeof(ti));
cfmakeraw(&ti);
+
tcsetattr(fd, TCSANOW, &ti);
return fd;
modem->channel = g_io_channel_unix_new(fd);
g_io_channel_set_close_on_unref(modem->channel, TRUE);
- g_io_add_watch(modem->channel,
+ modem->watch = g_io_add_watch(modem->channel,
G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
modem_event, modem);
if (modem == NULL)
return -ENOENT;
- g_io_channel_shutdown(modem->channel, TRUE, NULL);
- g_io_channel_unref(modem->channel);
+ g_source_remove(modem->watch);
+ modem->watch = 0;
+ g_io_channel_unref(modem->channel);
modem->channel = NULL;
return 0;