Design and Implementation of a Documentation Tool for ... - MADOC
Design and Implementation of a Documentation Tool for ... - MADOC
Design and Implementation of a Documentation Tool for ... - MADOC
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
winsize, used in chunks 18c, 30a, 31b, <strong>and</strong> 34c.<br />
Uses chunk11 18c, die 23b, <strong>and</strong> PTM 28c.<br />
Retrieving the window size requires ioctl.h <strong>for</strong> ioctl():<br />
31a 〈includes 8b〉+≡ (15b) ⊳ 28f 33b ⊲<br />
#include <br />
The client PTYs window size will be initialized now. This needs to take<br />
place be<strong>for</strong>e the client application is launched, because it probably requires<br />
an already configured terminal size when starting up. Writing the size to the<br />
transcript however would put the window size meta chunk be<strong>for</strong>e the start <strong>of</strong><br />
session chunk, there<strong>for</strong>e winsize()s mode 1 is used.<br />
31b 〈openpt 31b〉≡<br />
winsize(1);<br />
Uses winsize 30b.<br />
A.10 Running the Target Application<br />
The doshell() function is run in the child process, whose only task is to set up<br />
all required PTY redirections <strong>and</strong> then execute the client comm<strong>and</strong>. There<strong>for</strong>e,<br />
open file descriptors from the parent process which are no longer needed are<br />
closed early.<br />
31c 〈doshell 31c〉≡ (15c)<br />
void doshell() {<br />
close(PTM);<br />
fclose(OUTF);<br />
〈change the terminal 31d〉<br />
〈determine the shell 32b〉<br />
〈execute the shell 32d〉<br />
}<br />
Defines:<br />
doshell, used in chunk 9.<br />
Uses OUTF 22a <strong>and</strong> PTM 28c.<br />
Changing the Terminal<br />
Next, the child process changes its controlling terminal to be the PTY slave. In<br />
order to do that, it has to be placed in a separate session.<br />
31d 〈change the terminal 31d〉≡ (31c) 32a ⊲<br />
setsid();<br />
if (ioctl(PTS, TIOCSCTTY, 0) < 0) {<br />
perror("controlling terminal");<br />
die("controlling terminal failed", 0);<br />
}<br />
Uses die 23b.<br />
31