aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/terminal.go
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/terminal.go')
-rw-r--r--widgets/terminal.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/widgets/terminal.go b/widgets/terminal.go
index 1d4c1df3..e499e3e4 100644
--- a/widgets/terminal.go
+++ b/widgets/terminal.go
@@ -232,9 +232,6 @@ func (term *Terminal) invalidate() {
}
func (term *Terminal) Draw(ctx *ui.Context) {
- term.closeMutex.Lock()
- defer term.closeMutex.Unlock()
-
if term.destroyed {
return
}
@@ -252,7 +249,15 @@ func (term *Terminal) Draw(ctx *ui.Context) {
if term.pty == nil {
term.vterm.SetSize(ctx.Height(), ctx.Width())
+
+ term.closeMutex.Lock()
+ if term.cmd == nil {
+ term.closeMutex.Unlock()
+ return
+ }
tty, err := pty.StartWithAttrs(term.cmd, &winsize, &syscall.SysProcAttr{Setsid: true, Setctty: true, Ctty: 1})
+ term.closeMutex.Unlock()
+
term.pty = tty
if err != nil {
term.Close(err)