update debug log usage and add fanciness to log printing
This commit is contained in:
parent
91498926d5
commit
1f192607b2
8 changed files with 27 additions and 25 deletions
|
|
@ -45,8 +45,8 @@ func ShsProgn(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
* (if (eq (number "3") 3) (print "test passed") (print "test failed"))
|
||||
*/
|
||||
func ShsIf(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
||||
cond := in
|
||||
t := cond.Next
|
||||
cond := in.Copy()
|
||||
t := cond.Next.Copy()
|
||||
f := t.Next
|
||||
cond.Next = nil
|
||||
t.Next = nil
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
*/
|
||||
func Expand(input *ast.Token, vars ast.VarTable, funcs ast.FuncTable) *ast.Token {
|
||||
if input.Tag != ast.LIST {
|
||||
log.Log(log.DEBUG, "expand called on not a list", "expand")
|
||||
log.Log(log.INFO, "expand called on not a list", "expand")
|
||||
return input
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ var LastExitCode int
|
|||
func signalHandler() {
|
||||
for {
|
||||
<- sigChan
|
||||
log.Log(log.DEBUG,
|
||||
log.Log(log.INFO,
|
||||
"caught SIGINT",
|
||||
"jobctl")
|
||||
|
||||
|
|
@ -174,7 +174,11 @@ func LaunchProcess(
|
|||
stderr io.Writer ) {
|
||||
c, cancel := context.WithCancel(context.Background())
|
||||
cmd := exec.CommandContext(c, path, args...)
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Foreground: !background, Setpgid: true}
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
|
||||
if !background {
|
||||
cmd.SysProcAttr.Foreground = true
|
||||
}
|
||||
|
||||
if stdin == nil {
|
||||
stdin = os.Stdin
|
||||
|
|
@ -201,6 +205,7 @@ func LaunchProcess(
|
|||
CurCancel = &cancel
|
||||
|
||||
if background {
|
||||
cmd.Process.Signal(syscall.SIGTSTP)
|
||||
go func(){
|
||||
waitChan <- cmd.Wait()
|
||||
delete(JobMap, cpid)
|
||||
|
|
@ -317,7 +322,7 @@ func Fg(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
}
|
||||
|
||||
ipid := int(pid)
|
||||
proc, ok := JobMap[ipid]
|
||||
_, ok := JobMap[ipid]
|
||||
if !ok {
|
||||
log.Log(log.ERR,
|
||||
"Process not found, was it started by this shell?",
|
||||
|
|
@ -325,17 +330,7 @@ func Fg(in *ast.Token, vt ast.VarTable, ft ast.FuncTable) *ast.Token {
|
|||
return nil
|
||||
}
|
||||
|
||||
cmd := proc.Ctl
|
||||
cmd.Process.Signal(syscall.SIGCONT)
|
||||
err = cmd.Wait()
|
||||
if err != nil {
|
||||
if exitError, ok := err.(*exec.ExitError); ok {
|
||||
LastExitCode = exitError.ExitCode()
|
||||
} else {
|
||||
log.Log(log.ERR, "Execution step returned error: " + err.Error(), "call")
|
||||
}
|
||||
}
|
||||
|
||||
tcsetpgrp(0, ipid)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ func GenFuncTable() ast.FuncTable {
|
|||
Function: Fg,
|
||||
Name: "foreground",
|
||||
TimesCalled: 0,
|
||||
Args: 0,
|
||||
Args: 1,
|
||||
},
|
||||
|
||||
"$": &ast.Function{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue