1 |
On Friday 19 November 2004 11:41, Duncan Coutts wrote: |
2 |
> On Fri, 2004-11-19 at 04:03 -0500, Aaron Walker wrote: |
3 |
> > | function get-memory-total() { |
4 |
> > | cat /proc/meminfo | grep MemTotal | sed -r |
5 |
> > | "s/[^0-9]*([0-9]+).*/\1/" } |
6 |
> > |
7 |
> > eureka! what happens when the host OS doesn't have /proc/meminfo? |
8 |
> |
9 |
> [snip] |
10 |
> |
11 |
> > I have no problem with what the above code is trying to achieve, just |
12 |
> > how it goes about doing so. At the very least, it shouldn't assume |
13 |
> > the existence of a procfs. |
14 |
> > |
15 |
> > If you do decide to handle your problem by checking the amount of |
16 |
> > RAM, please find an alternate way (obviously 'free' can't be used |
17 |
> > either) or at the very minimum check for file existence. |
18 |
> |
19 |
> Can you think of a nice portable way of doing this test? That would be |
20 |
> really helpful. |
21 |
|
22 |
Maybe testing for the existence of /proc/meminfo can be used at least, and |
23 |
passing if it doesn't exist. |
24 |
|
25 |
Paul |
26 |
|
27 |
-- |
28 |
Paul de Vrieze |
29 |
Gentoo Developer |
30 |
Mail: pauldv@g.o |
31 |
Homepage: http://www.devrieze.net |