~ubuntu-branches/ubuntu/maverick/libvirt/maverick

« back to all changes in this revision

Viewing changes to src/console.c

Tags: upstream-0.6.4
Import upstream version 0.6.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
#include "console.h"
39
39
#include "internal.h"
 
40
#include "logging.h"
40
41
#include "util.h"
41
42
 
42
43
/* ie  Ctrl-]  as per telnet */
72
73
 
73
74
    /* We do not want this to become the controlling TTY */
74
75
    if ((ttyfd = open(tty, O_NOCTTY | O_RDWR)) < 0) {
75
 
        fprintf(stderr, _("unable to open tty %s: %s\n"),
76
 
                tty, strerror(errno));
 
76
        VIR_ERROR(_("unable to open tty %s: %s\n"),
 
77
                  tty, strerror(errno));
77
78
        return -1;
78
79
    }
79
80
 
83
84
       also ensure Ctrl-C, etc is blocked, and misc
84
85
       other bits */
85
86
    if (tcgetattr(STDIN_FILENO, &ttyattr) < 0) {
86
 
        fprintf(stderr, _("unable to get tty attributes: %s\n"),
87
 
                strerror(errno));
 
87
        VIR_ERROR(_("unable to get tty attributes: %s\n"),
 
88
                  strerror(errno));
88
89
        goto closetty;
89
90
    }
90
91
 
92
93
    cfmakeraw(&rawattr);
93
94
 
94
95
    if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &rawattr) < 0) {
95
 
        fprintf(stderr, _("unable to set tty attributes: %s\n"),
96
 
                strerror(errno));
 
96
        VIR_ERROR(_("unable to set tty attributes: %s\n"),
 
97
                  strerror(errno));
97
98
        goto closetty;
98
99
    }
99
100
 
127
128
            if (errno == EINTR || errno == EAGAIN)
128
129
                continue;
129
130
 
130
 
            fprintf(stderr, _("failure waiting for I/O: %s\n"),
131
 
                    strerror(errno));
 
131
            VIR_ERROR(_("failure waiting for I/O: %s\n"), strerror(errno));
132
132
            goto cleanup;
133
133
        }
134
134
 
142
142
                int got, sent = 0, destfd;
143
143
 
144
144
                if ((got = read(fds[i].fd, buf, sizeof(buf))) < 0) {
145
 
                    fprintf(stderr, _("failure reading input: %s\n"),
146
 
                            strerror(errno));
 
145
                    VIR_ERROR(_("failure reading input: %s\n"),
 
146
                              strerror(errno));
147
147
                    goto cleanup;
148
148
                }
149
149
 
164
164
                    int done;
165
165
                    if ((done = safewrite(destfd, buf + sent, got - sent))
166
166
                        <= 0) {
167
 
                        fprintf(stderr, _("failure writing output: %s\n"),
168
 
                                strerror(errno));
 
167
                        VIR_ERROR(_("failure writing output: %s\n"),
 
168
                                  strerror(errno));
169
169
                        goto cleanup;
170
170
                    }
171
171
                    sent += done;