void *logctx;
+static struct termios orig_termios;
+
void fatalbox(char *p, ...)
{
+ struct termios cf;
va_list ap;
+ premsg(&cf);
fprintf(stderr, "FATAL ERROR: ");
va_start(ap, p);
vfprintf(stderr, p, ap);
va_end(ap);
fputc('\n', stderr);
+ postmsg(&cf);
if (logctx) {
log_free(logctx);
logctx = NULL;
}
void modalfatalbox(char *p, ...)
{
+ struct termios cf;
va_list ap;
+ premsg(&cf);
fprintf(stderr, "FATAL ERROR: ");
va_start(ap, p);
vfprintf(stderr, p, ap);
va_end(ap);
fputc('\n', stderr);
+ postmsg(&cf);
if (logctx) {
log_free(logctx);
logctx = NULL;
}
void connection_fatal(void *frontend, char *p, ...)
{
+ struct termios cf;
va_list ap;
+ premsg(&cf);
fprintf(stderr, "FATAL ERROR: ");
va_start(ap, p);
vfprintf(stderr, p, ap);
va_end(ap);
fputc('\n', stderr);
+ postmsg(&cf);
if (logctx) {
log_free(logctx);
logctx = NULL;
}
void cmdline_error(char *p, ...)
{
+ struct termios cf;
va_list ap;
+ premsg(&cf);
fprintf(stderr, "plink: ");
va_start(ap, p);
vfprintf(stderr, p, ap);
va_end(ap);
fputc('\n', stderr);
+ postmsg(&cf);
exit(1);
}
static int local_tty = FALSE; /* do we have a local tty? */
-static struct termios orig_termios;
static Backend *back;
static void *backhandle;
bufchain *chain = (is_stderr ? &stderr_data : &stdout_data);
int fd = (is_stderr ? STDERR_FILENO : STDOUT_FILENO);
void *senddata;
- int sendlen, ret;
+ int sendlen, ret, fl;
if (bufchain_size(chain) == 0)
return;
bufchain_prefix(chain, &senddata, &sendlen);
+ fl = fcntl(fd, F_GETFL);
+ if (fl != -1 && !(fl & O_NONBLOCK))
+ fcntl(fd, F_SETFL, fl | O_NONBLOCK);
ret = write(fd, senddata, sendlen);
+ if (fl != -1 && !(fl & O_NONBLOCK))
+ fcntl(fd, F_SETFL, fl);
if (ret > 0)
bufchain_consume(chain, ret);
- else if (ret < 0) {
+ else if (ret < 0 && errno != EAGAIN) {
perror(is_stderr ? "stderr: write" : "stdout: write");
exit(1);
}
default_protocol = PROT_SSH;
default_port = 22;
- flags = FLAG_STDERR;
+ flags = FLAG_STDERR | FLAG_STDERR_TTY;
+
+ stderr_tty_init();
/*
* Process the command line.
*/