#include <sys/socket.h>
#include "kern_util.h"
#include "chan_user.h"
-#include "helper.h"
#include "user_util.h"
#include "user.h"
#include "os.h"
int direct_rcv;
};
+/* Not static because it's called directly by the tt mode gdb code */
void *xterm_init(char *str, int device, struct chan_opts *opts)
{
struct xterm_chan *data;
" are 'xterm=gnome-terminal,-t,-x'.\n\n"
);
-/* XXX This badly needs some cleaning up in the error paths */
-int xterm_open(int input, int output, int primary, void *d, char **dev_out)
+/* XXX This badly needs some cleaning up in the error paths
+ * Not static because it's called directly by the tt mode gdb code
+ */
+int xterm_open(int input, int output, int primary, void *d,
+ char **dev_out)
{
struct xterm_chan *data = d;
unsigned long stack;
if(os_access(argv[4], OS_ACC_X_OK) < 0)
argv[4] = "port-helper";
+ /* Check that DISPLAY is set, this doesn't guarantee the xterm
+ * will work but w/o it we can be pretty sure it won't. */
+ if (!getenv("DISPLAY")) {
+ printk("xterm_open: $DISPLAY not set.\n");
+ return -ENODEV;
+ }
+
fd = mkstemp(file);
if(fd < 0){
+ err = -errno;
printk("xterm_open : mkstemp failed, errno = %d\n", errno);
- return(-errno);
+ return err;
}
if(unlink(file)){
+ err = -errno;
printk("xterm_open : unlink failed, errno = %d\n", errno);
- return(-errno);
+ return err;
}
os_close_file(fd);
if(data->stack == 0) free_stack(stack, 0);
- if(data->direct_rcv)
+ if (data->direct_rcv) {
new = os_rcv_fd(fd, &data->helper_pid);
- else {
+ } else {
err = os_set_fd_block(fd, 0);
if(err < 0){
printk("xterm_open : failed to set descriptor "
return(new);
}
+/* Not static because it's called directly by the tt mode gdb code */
void xterm_close(int fd, void *d)
{
struct xterm_chan *data = d;
os_close_file(fd);
}
-void xterm_free(void *d)
+static void xterm_free(void *d)
{
free(d);
}
-int xterm_console_write(int fd, const char *buf, int n, void *d)
-{
- struct xterm_chan *data = d;
-
- return(generic_console_write(fd, buf, n, &data->tt));
-}
-
struct chan_ops xterm_ops = {
.type = "xterm",
.init = xterm_init,
.close = xterm_close,
.read = generic_read,
.write = generic_write,
- .console_write = xterm_console_write,
+ .console_write = generic_console_write,
.window_size = generic_window_size,
.free = xterm_free,
.winch = 1,