From 23d51af24fe3da370bd20a7a63ec5d6fd5dcd588 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 16 Jan 2013 07:27:53 +0100 Subject: [PATCH] store pid of process and return instead of exit into Sac_a_push::run method --- web/Obj/sac-a-push.phh | 30 +++++++++++++++++++++++++----- web/spush/brisk-spush.php | 24 +++++++++++++++--------- 2 files changed, 40 insertions(+), 14 deletions(-) diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index ee30cea..441d2eb 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -1,6 +1,6 @@ list) { printf("Arrivati %d bytes da list\n", strlen($buf)); - exit(21); + return(21); } else if ($sock === $this->in) { printf("Arrivati %d bytes da stdin\n", strlen($buf)); - exit(22); + return(22); } else { // $user_a[$s2u[intval($sock)]]->disable(); @@ -606,10 +626,10 @@ class Sac_a_push { } else if ($line == "shutdown") { if ($this->app->dump_data()) { - exit(0); + return(0); } else { - exit(1); + return(1); } } } diff --git a/web/spush/brisk-spush.php b/web/spush/brisk-spush.php index 8eece0c..9a65d21 100755 --- a/web/spush/brisk-spush.php +++ b/web/spush/brisk-spush.php @@ -41,18 +41,24 @@ require_once($G_base."briskin5/index_wr.php"); function main() { - if (($room = Room::create(LEGAL_PATH."/brisk-crystal.data")) == FALSE) { - log_crit("room::create failed"); - exit(1); - } + pid_save(); + do { + if (($room = Room::create(LEGAL_PATH."/brisk-crystal.data")) == FALSE) { + log_crit("room::create failed"); + $ret = 1; + break; + } - if (($s_a_p = Sac_a_push::create($room, USOCK_PATH, 0, 0)) === FALSE) { - exit(1); - } + if (($s_a_p = Sac_a_push::create($room, USOCK_PATH, 0, 0)) === FALSE) { + $ret = 2; + break; + } - $s_a_p->run(); + $ret = $s_a_p->run(); + } while (0); - exit(0); + pid_remove(); + exit($ret); } main(); -- 2.17.1