]> git.lizzy.rs Git - micro.git/blob - cmd/micro/actions_posix.go
Merge pull request #1125 from nabeelomer/master
[micro.git] / cmd / micro / actions_posix.go
1 // +build linux darwin dragonfly solaris openbsd netbsd freebsd
2
3 package main
4
5 import "syscall"
6
7 // Suspend sends micro to the background. This is the same as pressing CtrlZ in most unix programs.
8 // This only works on linux and has no default binding.
9 // This code was adapted from the suspend code in nsf/godit
10 func (v *View) Suspend(usePlugin bool) bool {
11         if usePlugin && !PreActionCall("Suspend", v) {
12                 return false
13         }
14
15         screenWasNil := screen == nil
16
17         if !screenWasNil {
18                 screen.Fini()
19                 screen = nil
20         }
21
22         // suspend the process
23         pid := syscall.Getpid()
24         err := syscall.Kill(pid, syscall.SIGSTOP)
25         if err != nil {
26                 TermMessage(err)
27         }
28
29         if !screenWasNil {
30                 InitScreen()
31         }
32
33         if usePlugin {
34                 return PostActionCall("Suspend", v)
35         }
36         return true
37 }