Fixed bug where returning errors overwrote environment

This commit is contained in:
Mikhail Kiselev 2023-08-10 14:42:59 -05:00
parent 486c96fa19
commit bcd027b6de
Signed by: Sangui
GPG key ID: DAB055E38B47526A
2 changed files with 5 additions and 3 deletions

2
lsm.1
View file

@ -2,7 +2,7 @@
.SH NAME .SH NAME
lsm \- local service manager lsm \- local service manager
.SH SYNOPSIS .SH SYNOPSIS
.B lsm .B lsm
.I <directive> .I <directive>
.R [options] .R [options]
.SH DESCRIPTION .SH DESCRIPTION

View file

@ -99,7 +99,7 @@
(return-from start (neterr 12 "start" progr))) (return-from start (neterr 12 "start" progr)))
(envline (envline
(cond ((uiop:process-alive-p (getf envline :nfo)) (cond ((uiop:process-alive-p (getf envline :nfo))
(return-from start (neterr 16 "start" progr))) (return-from start (values (neterr 16 "start" progr) env)))
(t (t
(setf env (delete-db env :prog progr)))))) (setf env (delete-db env :prog progr))))))
@ -134,7 +134,7 @@
(cond ((getf progline :secs) (cond ((getf progline :secs)
(sleep (parse-integer *)) ;Should work here I think. also remember to do config checking rather than parsing the int here. (sleep (parse-integer *)) ;Should work here I think. also remember to do config checking rather than parsing the int here.
(cond ((plusp (slot-value nfo 'uiop/launch-program::exit-code)) (cond ((plusp (slot-value nfo 'uiop/launch-program::exit-code))
(return-from start (neterr 13 progr)))))) ;TODO: Turn this into an AND or something cuz it's ugly (return-from start (values (neterr 13 progr) env)))))) ;TODO: Turn this into an AND or something cuz it's ugly
(values "0" (push (list :prog progr :nfo nfo :time (get-unix-time) :ll 0) env)))) (values "0" (push (list :prog progr :nfo nfo :time (get-unix-time) :ll 0) env))))
) )
@ -142,12 +142,14 @@
(defun stop(progs env progr) (defun stop(progs env progr)
(let ((progline (select-db progs :prog progr)) (let ((progline (select-db progs :prog progr))
(nfo (select-dbp env progr :nfo))) (nfo (select-dbp env progr :nfo)))
(cond ((not progline) (cond ((not progline)
(return-from stop (neterr 14 "stop" progr))) (return-from stop (neterr 14 "stop" progr)))
((not nfo) ((not nfo)
(return-from stop (neterr 15 "stop" progr))) (return-from stop (neterr 15 "stop" progr)))
((not (uiop:process-alive-p nfo)) ((not (uiop:process-alive-p nfo))
(return-from stop (neterr 17 "stop" progr)))) ;TODO: make this only send progr [keywords maybe?] - also, might want better control flow here. (return-from stop (neterr 17 "stop" progr)))) ;TODO: make this only send progr [keywords maybe?] - also, might want better control flow here.
(let ((stop (select-dbp progs progr :stop))) (let ((stop (select-dbp progs progr :stop)))
(cond (stop (cond (stop
(uiop:run-program stop)) (uiop:run-program stop))