@@ -80,15 +80,15 @@ func (c *SCmd) transform(line string) string {
80
80
return line
81
81
}
82
82
83
- func (c * SCmd ) Run (ctx context.Context ) (code int64 , err error ) {
83
+ func (c * SCmd ) Run (ctx context.Context ) (exit int64 , err error ) {
84
84
defer func () {
85
85
c .cancel ()
86
86
if _r := recover (); _r != nil {
87
87
err = fmt .Errorf ("panic during execution %v" , _r )
88
- code = common .CodeSystemErr
88
+ exit = common .CodeSystemErr
89
89
stack := debug .Stack ()
90
90
if _err , ok := _r .(error ); ok && strings .Contains (_err .Error (), context .Canceled .Error ()) {
91
- code = common .CodeKilled
91
+ exit = common .CodeKilled
92
92
err = common .ErrManual
93
93
}
94
94
c .storage .Log ().Write (err .Error (), string (stack ))
@@ -138,14 +138,14 @@ func (c *SCmd) Run(ctx context.Context) (code int64, err error) {
138
138
go c .writeKeepAlive (ppty )
139
139
err = cmd .Run ()
140
140
if cmd .ProcessState != nil {
141
- code = int64 (cmd .ProcessState .ExitCode ())
141
+ exit = int64 (cmd .ProcessState .ExitCode ())
142
142
if cmd .ProcessState .Pid () != 0 {
143
143
_ = syscall .Kill (- cmd .ProcessState .Pid (), syscall .SIGKILL )
144
144
c .reaper (cmd .ProcessState .Pid ())
145
145
}
146
146
}
147
- if err != nil && code == 0 {
148
- code = common .CodeFailed
147
+ if err != nil && exit == 0 {
148
+ exit = common .CodeFailed
149
149
}
150
150
writer .AutoStop = true
151
151
if _ , _err := tty .Write ([]byte ("\x04 " )); _err != nil {
@@ -157,10 +157,10 @@ func (c *SCmd) Run(ctx context.Context) (code int64, err error) {
157
157
switch {
158
158
case errors .Is (context .Cause (c .ctx ), common .ErrTimeOut ):
159
159
err = common .ErrTimeOut
160
- code = common .CodeTimeout
160
+ exit = common .CodeTimeout
161
161
default :
162
162
err = common .ErrManual
163
- code = common .CodeKilled
163
+ exit = common .CodeKilled
164
164
}
165
165
}
166
166
return
0 commit comments