/
doc.go
46 lines (39 loc) · 2.17 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) 2019, 2021, AT&T Intellectual Property. All rights reserved.
//
// Copyright (c) 2013-2016 by Brocade Communications Systems, Inc.
// All rights reserved.
//
// SPDX-License-Identifier: LGPL-2.1-only
/*
runner fork/exec's the requested child process connected to a
pty passed in from the client. If the pty doesn't exist the
process will fail. The cmdclient package creates a pty. The pty
file descriptor is passed to the cmdrunner via an SCM_RIGHTS
ancilliary message passed via main.sock. This is done through the opd
Run RPC. Run now blocks until the process exits and returns the exit
code from the opd child.
A diagram of how process spawning works is included below:
+---------------+ main.sock +----------------------+
| +------------------>+ |
| opc +<------------------+ opd |
| | | |
|.+-----------+.| |.+------------------+.|
++ ++ ++ ++
|| cmdc || || cmdrunner ||
++ ++ ++ ++
|'+-----------+'| |'+------------------+'|
+^-+--------+-^-+ +----------------------+
| | | | |fork/exec
| | | | V
in/out | | .+-----------+.
| | | | + requested +
| | in/out + process +
+-+-v--+ | | '+---^-+-----+'
| tty | | | | |
+------+ | | in/out
+------+ | | | |
| user | +---v-+-----------------------------------+-V--------+
+------+ | PTY |
+----------------------------------------------------+
*/
package main