annotate toys/pending/openvt.c @ 1214:a31d747b0017 draft

Please find the patches attached herewith for adding 3 new commands - 1. freeramdisk - If we unmount or detach the RAM disk based file system the Linux Kernel will not free the allocated memory associated with the RAM device. This can be useful if one wants to mount this device again: All data will be preserved. If we need to free the memory back to the Kernel, one can use the command: "toybox freeramdisk <RAM device>". 2. openvt - Successfully opens a new virtual terminal as mentioned with -c option otherwise search and open next available VT. with -s option it switches to new VT with -s -w option, it switch back successfully to originating VT. 3. deallocvt - Deallocate specified virtual teminal. if no virtual terminal is specified, it deallocates all unused VT.
author Vivek Bhagat <vivek.bhagat89@gmail.com>
date Sun, 09 Mar 2014 14:27:11 -0500
parents
children 3c855d5a75be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1214
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
1 /* openvt.c - Run a program on a new VT
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
2 *
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
3 * Copyright 2014 Vivek Kumar Bhagat <vivek.bhagat89@gmail.com>
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
4 *
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
5 * No Standard
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
6
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
7 USE_OPENVT(NEWTOY(openvt, "c#<1>63sw", TOYFLAG_BIN|TOYFLAG_NEEDROOT))
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
8
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
9 config OPENVT
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
10 bool "openvt"
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
11 default n
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
12 help
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
13 usage: openvt [-c N] [-s] [-w] [--] [command [command_options]]
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
14
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
15 start a program on a new virtual terminal (VT)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
16
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
17 -c N Use VT N
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
18 -s Switch to new VT
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
19 -w Wait for command to exit
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
20 if -s and -w option used together, switch back
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
21 to originating VT when command completes
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
22 */
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
23
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
24 #define FOR_openvt
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
25 #include "toys.h"
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
26 #include <linux/vt.h>
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
27 #include <linux/kd.h>
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
28
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
29 GLOBALS(
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
30 unsigned long vt_num;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
31 )
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
32
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
33 int find_console_fd(void)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
34 {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
35 char *console_name[] = {"/dev/tty", "/dev/tty0", "/dev/console"};
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
36 int i;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
37 int fd;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
38 char arg;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
39
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
40 for (i = 0; i < 3; i++) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
41 fd = open(console_name[i], O_RDWR);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
42 if (fd < 0 && errno == EACCES)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
43 fd = open(console_name[i], O_RDONLY);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
44
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
45 if (fd < 0 && errno == EACCES)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
46 fd = open(console_name[i], O_WRONLY);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
47
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
48 if (fd >= 0) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
49 arg = 0;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
50 if (0 == ioctl(fd, KDGKBTYPE, &arg))
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
51 return fd;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
52 else
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
53 close(fd);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
54 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
55 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
56
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
57 /* check std fd 0, 1 and 2 */
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
58 for (fd = 0; fd < 3; fd++) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
59 arg = 0;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
60 if (0 == ioctl(fd, KDGKBTYPE, &arg))
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
61 return fd;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
62 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
63
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
64 return -1;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
65 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
66
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
67 int xvtnum(int fd)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
68 {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
69 int ret;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
70
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
71 ret = ioctl(fd, VT_OPENQRY, (int *)&TT.vt_num);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
72 if (ret != 0 || TT.vt_num <= 0) perror_exit("can't find open VT");
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
73
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
74 return TT.vt_num;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
75 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
76
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
77 void openvt_main(void)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
78 {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
79 int fd = -1, vt_fd = -1, pid, ret = 0;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
80 struct vt_stat vstate;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
81
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
82 if (!(toys.optflags & FLAG_c)) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
83 // check if fd 0,1 or 2 is already opened
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
84 for (fd = 0; fd < 3; fd++)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
85 if (!ioctl(fd, VT_GETSTATE, &vstate)) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
86 ret = xvtnum(fd);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
87 break;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
88 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
89
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
90 // find VT number using /dev/console
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
91 if (!ret) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
92 fd = xopen("/dev/console", O_RDONLY | O_NONBLOCK);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
93 xioctl(fd, VT_GETSTATE, &vstate);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
94 xvtnum(fd);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
95 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
96 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
97
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
98 sprintf(toybuf, "/dev/tty%lu", TT.vt_num);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
99 fd = find_console_fd();
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
100 xioctl(fd, VT_GETSTATE, &vstate);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
101
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
102 close(0); //new vt becomes stdin
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
103 vt_fd = xopen(toybuf, O_RDWR);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
104 if (toys.optflags & FLAG_s) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
105 ioctl(vt_fd, VT_ACTIVATE, TT.vt_num);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
106 ioctl(vt_fd, VT_WAITACTIVE, TT.vt_num);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
107 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
108
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
109 close(1);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
110 close(2);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
111 dup2(vt_fd, 1);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
112 dup2(vt_fd, 2);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
113 while (vt_fd > 2)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
114 close(vt_fd--);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
115
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
116 pid = vfork();
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
117 if (pid < 0) perror_exit("Fork failed");
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
118 else if (!pid) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
119 setsid();
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
120 ioctl(vt_fd, TIOCSCTTY, 0);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
121 xexec(toys.optargs);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
122 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
123
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
124 if (toys.optflags & FLAG_w) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
125 while (-1 == waitpid(pid, NULL, 0) && errno == EINTR)
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
126 ;
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
127 if (toys.optflags & FLAG_s) {
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
128 ioctl(fd, VT_ACTIVATE, vstate.v_active);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
129 ioctl(fd, VT_WAITACTIVE, vstate.v_active);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
130 //check why deallocate isn't working here
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
131 xioctl(fd, VT_DISALLOCATE, (void *)(ptrdiff_t)TT.vt_num);
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
132 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
133 }
a31d747b0017 Please find the patches attached herewith for adding 3 new commands -
Vivek Bhagat <vivek.bhagat89@gmail.com>
parents:
diff changeset
134 }