-rw-r--r-- | noncore/apps/opie-console/procctl.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp index a44529b..5239e26 100644 --- a/noncore/apps/opie-console/procctl.cpp +++ b/noncore/apps/opie-console/procctl.cpp | |||
@@ -28,49 +28,52 @@ void ProcCtl::add(pid_t pi, int fd ) { | |||
28 | con->prev = m_last; | 28 | con->prev = m_last; |
29 | 29 | ||
30 | m_last = con; | 30 | m_last = con; |
31 | 31 | ||
32 | } | 32 | } |
33 | void ProcCtl::remove( pid_t pi ) { | 33 | void ProcCtl::remove( pid_t pi ) { |
34 | /* | 34 | /* |
35 | * We first check if the last item | 35 | * We first check if the last item |
36 | * is equal to pi the we | 36 | * is equal to pi the we |
37 | * | 37 | * |
38 | */ | 38 | */ |
39 | ProcContainer* con; | 39 | ProcContainer* con; |
40 | if (m_last->pid == pi ) { | 40 | if (m_last->pid == pi ) { |
41 | con = m_last; | 41 | con = m_last; |
42 | m_last = con->prev; | 42 | m_last = con->prev; |
43 | delete con; | 43 | delete con; |
44 | return; | 44 | return; |
45 | } | 45 | } |
46 | 46 | ||
47 | con = m_last; | 47 | con = m_last; |
48 | ProcContainer* forw = 0l; | 48 | ProcContainer* forw = 0l; |
49 | while (con ) { | 49 | while (con ) { |
50 | /* remove it */ | 50 | /* remove it */ |
51 | if ( pi == con->pid ) { | 51 | if ( pi == con->pid ) { |
52 | forw->prev = con->prev; | 52 | if (forw) |
53 | forw->prev = con->prev; | ||
54 | else | ||
55 | forw = con->prev; | ||
53 | delete con; | 56 | delete con; |
54 | return; | 57 | return; |
55 | } | 58 | } |
56 | 59 | ||
57 | forw = con; | 60 | forw = con; |
58 | con = con->prev; | 61 | con = con->prev; |
59 | } | 62 | } |
60 | 63 | ||
61 | } | 64 | } |
62 | void ProcCtl::remove( ProcContainer con ) { | 65 | void ProcCtl::remove( ProcContainer con ) { |
63 | remove( con.pid ); | 66 | remove( con.pid ); |
64 | } | 67 | } |
65 | int ProcCtl::status(pid_t pid )const{ | 68 | int ProcCtl::status(pid_t pid )const{ |
66 | ProcContainer *con = m_last; | 69 | ProcContainer *con = m_last; |
67 | while (con) { | 70 | while (con) { |
68 | if (con->pid == pid ) | 71 | if (con->pid == pid ) |
69 | return con->status; | 72 | return con->status; |
70 | con = con->prev; | 73 | con = con->prev; |
71 | } | 74 | } |
72 | return -1; | 75 | return -1; |
73 | } | 76 | } |
74 | void ProcCtl::signal_handler(int) { | 77 | void ProcCtl::signal_handler(int) { |
75 | int status; | 78 | int status; |
76 | signal( SIGCHLD, signal_handler ); | 79 | signal( SIGCHLD, signal_handler ); |