I've just discovered that using the saved sessions menu from Unix
[u/mdw/putty] / unix / uxser.c
index db98dd8..08f2157 100644 (file)
@@ -162,9 +162,15 @@ static const char *serial_configure(Serial serial, Config *cfg)
     logevent(serial->frontend, msg);
     sfree(msg);
 
-    options.c_cflag &= ~(IXON|IXOFF);
+    options.c_iflag &= ~(IXON|IXOFF);
+#ifdef CRTSCTS
+    options.c_cflag &= ~CRTSCTS;
+#endif
+#ifdef CNEW_RTSCTS
+    options.c_cflag &= ~CNEW_RTSCTS;
+#endif
     if (cfg->serflow == SER_FLOW_XONXOFF) {
-       options.c_cflag |= IXON | IXOFF;
+       options.c_iflag |= IXON | IXOFF;
        str = "XON/XOFF";
     } else if (cfg->serflow == SER_FLOW_RTSCTS) {
 #ifdef CRTSCTS
@@ -199,7 +205,16 @@ static const char *serial_configure(Serial serial, Config *cfg)
 
     options.c_cflag |= CLOCAL | CREAD;
     options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
-    options.c_oflag &= ~OPOST;
+    options.c_iflag &= ~(ISTRIP | IGNCR | INLCR | ICRNL
+#ifdef IUCLC
+                        | IUCLC
+#endif
+                        );
+    options.c_oflag &= ~(OPOST
+#ifdef ONLCR
+                        | ONLCR
+#endif
+                        | OCRNL | ONOCR | ONLRET);
     options.c_cc[VMIN] = 1;
     options.c_cc[VTIME] = 0;
 
@@ -242,6 +257,8 @@ static const char *serial_init(void *frontend_handle, void **backend_handle,
     if (serial->fd < 0)
        return "Unable to open serial port";
 
+    fcntl(serial->fd, F_SETFD, FD_CLOEXEC);
+
     err = serial_configure(serial, cfg);
     if (err)
        return err;