in C or bash,
I was wondering how, if possible, do you obtain from inside an ssh session, the file descriptor to the pseudo terminal master responsible for getting input to that’s session’s slave(pts).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The shell process has no master file descriptor, only slave.
The shell’s parent process (be it sshd or xterm or screen or whatever) creates a new master by calling
getpt(3)orposix_openpt(3). The function returns the master file descriptor. The parent process then obtains the slave file descriptor by calling a combination ofgrantpt(3),unlockpt(3),ptsname(3)andopen(2). This is for Linux and other POSIXized systems, other *nixes may use other functions, but the net result is the same. The parent process has the master/slave pair of file descriptors.The slave descriptor, and the slave descriptor only, is then passed to the shell as its standard input, output and error.