summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-12 00:40:14 (UTC)
committer zecke <zecke>2002-10-12 00:40:14 (UTC)
commit39b88e5809e50a4951869434b8015c55265fc495 (patch) (unidiff)
treead444833b2c9fd0c672c7dfdcc99b3a33ace8b8d
parent0a3ffe7e5657bed4cb77d9bc23457755e2d02591 (diff)
downloadopie-39b88e5809e50a4951869434b8015c55265fc495.zip
opie-39b88e5809e50a4951869434b8015c55265fc495.tar.gz
opie-39b88e5809e50a4951869434b8015c55265fc495.tar.bz2
No does not have any public c'tor
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/procctl.cpp6
-rw-r--r--noncore/apps/opie-console/procctl.h5
2 files changed, 10 insertions, 1 deletions
diff --git a/noncore/apps/opie-console/procctl.cpp b/noncore/apps/opie-console/procctl.cpp
index 6839a84..ff6bea8 100644
--- a/noncore/apps/opie-console/procctl.cpp
+++ b/noncore/apps/opie-console/procctl.cpp
@@ -1,62 +1,68 @@
1#include <sys/wait.h> 1#include <sys/wait.h>
2 2
3#include <fcntl.h> 3#include <fcntl.h>
4#include <unistd.h> 4#include <unistd.h>
5 5
6#include "procctl.h" 6#include "procctl.h"
7 7
8ProcContainer *ProcCtl::m_last = 0; 8ProcContainer *ProcCtl::m_last = 0;
9ProcCtl* ProcCtl::m_self = 0;
9 10
10ProcCtl::ProcCtl() { 11ProcCtl::ProcCtl() {
11 signal( SIGCHLD, signal_handler ); 12 signal( SIGCHLD, signal_handler );
12} 13}
13ProcCtl::~ProcCtl() { 14ProcCtl::~ProcCtl() {
14} 15}
16ProcCtl* ProcCtl::self() {
17 if (!m_self ) {
18 m_self = new ProcCtl;
19 }
20}
15void ProcCtl::add(pid_t pi, int fd ) { 21void ProcCtl::add(pid_t pi, int fd ) {
16 ProcContainer * con = new ProcContainer; 22 ProcContainer * con = new ProcContainer;
17 //memset(con, 0, sizeof(con) ); 23 //memset(con, 0, sizeof(con) );
18 con->pid = pi; 24 con->pid = pi;
19 con->fd = fd; 25 con->fd = fd;
20 con->status = 0; 26 con->status = 0;
21 con->prev = m_last; 27 con->prev = m_last;
22 28
23 m_last = con; 29 m_last = con;
24 30
25} 31}
26void ProcCtl::remove( pid_t pi ) { 32void ProcCtl::remove( pid_t pi ) {
27 /* 33 /*
28 * We first check if the last item 34 * We first check if the last item
29 * is equal to pi the we 35 * is equal to pi the we
30 * 36 *
31 */ 37 */
32 ProcContainer* con; 38 ProcContainer* con;
33 if (m_last->pid == pi ) { 39 if (m_last->pid == pi ) {
34 con = m_last; 40 con = m_last;
35 m_last = con->prev; 41 m_last = con->prev;
36 delete con; 42 delete con;
37 return; 43 return;
38 } 44 }
39 45
40 con = m_last; 46 con = m_last;
41 ProcContainer* forw = 0l; 47 ProcContainer* forw = 0l;
42 while (con ) { 48 while (con ) {
43 /* remove it */ 49 /* remove it */
44 if ( pi == con->pid ) { 50 if ( pi == con->pid ) {
45 forw->prev = con->prev; 51 forw->prev = con->prev;
46 delete con; 52 delete con;
47 return; 53 return;
48 } 54 }
49 55
50 forw = con; 56 forw = con;
51 con = con->prev; 57 con = con->prev;
52 } 58 }
53 59
54} 60}
55void ProcCtl::remove( ProcContainer con ) { 61void ProcCtl::remove( ProcContainer con ) {
56 remove( con.pid ); 62 remove( con.pid );
57} 63}
58int ProcCtl::status(pid_t pid )const{ 64int ProcCtl::status(pid_t pid )const{
59 ProcContainer *con = m_last; 65 ProcContainer *con = m_last;
60 while (con) { 66 while (con) {
61 if (con->pid == pid ) 67 if (con->pid == pid )
62 return con->status; 68 return con->status;
diff --git a/noncore/apps/opie-console/procctl.h b/noncore/apps/opie-console/procctl.h
index e2161f3..5e96423 100644
--- a/noncore/apps/opie-console/procctl.h
+++ b/noncore/apps/opie-console/procctl.h
@@ -1,33 +1,36 @@
1#ifndef OPIE_PROC_CTL_H 1#ifndef OPIE_PROC_CTL_H
2#define OPIE_PROC_CTL_H 2#define OPIE_PROC_CTL_H
3 3
4#include <sys/types.h> 4#include <sys/types.h>
5#include <unistd.h> 5#include <unistd.h>
6#include <fcntl.h> 6#include <fcntl.h>
7#include <signal.h> 7#include <signal.h>
8 8
9#include <qmap.h> 9#include <qmap.h>
10 10
11 11
12struct ProcContainer { 12struct ProcContainer {
13 pid_t pid; 13 pid_t pid;
14 int fd; 14 int fd;
15 int status; 15 int status;
16 ProcContainer* prev; 16 ProcContainer* prev;
17}; 17};
18 18
19class ProcCtl { 19class ProcCtl {
20public: 20private:
21 ProcCtl(); 21 ProcCtl();
22public:
22 ~ProcCtl(); 23 ~ProcCtl();
23 24
25 ProcCtl* self();
24 int status(pid_t)const; 26 int status(pid_t)const;
25 void add( pid_t, int fd ); 27 void add( pid_t, int fd );
26 void remove( pid_t ); 28 void remove( pid_t );
27 void remove( ProcContainer ); 29 void remove( ProcContainer );
28private: 30private:
29 static void signal_handler(int); 31 static void signal_handler(int);
30 static ProcContainer* m_last; 32 static ProcContainer* m_last;
33 static ProcCtl* m_self;
31}; 34};
32 35
33#endif 36#endif