diff -r 7bc59ff7fd31 -r 60a0efeec606 ChangeLog
--- a/ChangeLog Thu Feb 07 20:59:16 2013 +0100
+++ b/ChangeLog Thu Feb 07 21:00:08 2013 +0100
@@ -1,3 +1,9 @@
+2013-02-07 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
+
+ * src/main.c, src/minicom.h, src/updown.c:
+ [#314018] [PATCH] Disabling lockfile warnings when the
+ device disappears (ttyUSB hot-unplug), by Jaromir Capik
+
2013-02-06 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
* NEWS: Release 2.6.2
diff -r 7bc59ff7fd31 -r 60a0efeec606 src/main.c
--- a/src/main.c Thu Feb 07 20:59:16 2013 +0100
+++ b/src/main.c Thu Feb 07 21:00:08 2013 +0100
@@ -225,7 +225,7 @@
}
#endif
- if (doinit > 0 && lockfile_create() != 0)
+ if (doinit > 0 && lockfile_create(no_msgs) != 0)
return -1;
nolock:
diff -r 7bc59ff7fd31 -r 60a0efeec606 src/minicom.h
--- a/src/minicom.h Thu Feb 07 20:59:16 2013 +0100
+++ b/src/minicom.h Thu Feb 07 21:00:08 2013 +0100
@@ -301,7 +301,7 @@
void domacros(void);
-int lockfile_create(void);
+int lockfile_create(int no_msgs);
void lockfile_remove(void);
diff -r 7bc59ff7fd31 -r 60a0efeec606 src/updown.c
--- a/src/updown.c Thu Feb 07 20:59:16 2013 +0100
+++ b/src/updown.c Thu Feb 07 21:00:08 2013 +0100
@@ -413,7 +413,7 @@
if (win == (WIN *)0)
mc_wreturn();
- lockfile_create();
+ lockfile_create(0);
/* MARK updated 02/17/94 - Flush modem port before displaying READY msg */
/* because a BBS often displays menu text right after a download, and we */
@@ -459,7 +459,7 @@
#endif
}
-int lockfile_create(void)
+int lockfile_create(int no_msgs)
{
int n;
@@ -474,25 +474,29 @@
n = umask(022);
/* Create lockfile compatible with UUCP-1.2 */
if ((fd = open(lockfile, O_WRONLY | O_CREAT | O_EXCL, 0666)) < 0) {
- werror(_("Cannot create lockfile!"));
+ if (!no_msgs)
+ werror(_("Cannot create lockfile!"));
} else {
// FHS format:
char buf[12];
snprintf(buf, sizeof(buf), "%10d\n", getpid());
buf[sizeof(buf) - 1] = 0;
if (write(fd, buf, strlen(buf)) < (ssize_t)strlen(buf))
- fprintf(stderr, _("Failed to write lockfile %s\n"), lockfile);
+ if (!no_msgs)
+ fprintf(stderr, _("Failed to write lockfile %s\n"), lockfile);
close(fd);
}
umask(n);
return 0;
#else
n = ttylock(dial_tty);
- if (n < 0) {
- fprintf(stderr, _("Cannot create lockfile for %s: %s\n"), dial_tty, strerror(-n));
- } else if (n > 0) {
- fprintf(stderr, _("Device %s is locked.\n"), dial_tty);
- }
+ if (!no_msgs)
+ {
+ if (n < 0)
+ fprintf(stderr, _("Cannot create lockfile for %s: %s\n"), dial_tty, strerror(-n));
+ else if (n > 0)
+ fprintf(stderr, _("Device %s is locked.\n"), dial_tty);
+ }
return n;
#endif
}
@@ -546,7 +550,7 @@
mc_wreturn();
/* Re-create lockfile */
- lockfile_create();
+ lockfile_create(0);
m_flush(portfd);
port_init();