1 |
-----BEGIN PGP SIGNED MESSAGE----- |
2 |
Hash: SHA1 |
3 |
|
4 |
|
5 |
On Nov 19, 2004, at 4:41 AM, Duncan Coutts wrote: |
6 |
|
7 |
> On Fri, 2004-11-19 at 04:03 -0500, Aaron Walker wrote: |
8 |
> |
9 |
>> | |
10 |
>> | function get-memory-total() { |
11 |
>> | cat /proc/meminfo | grep MemTotal | sed -r |
12 |
>> "s/[^0-9]*([0-9]+).*/\1/" |
13 |
>> | } |
14 |
>> |
15 |
>> eureka! what happens when the host OS doesn't have /proc/meminfo? |
16 |
> |
17 |
> [snip] |
18 |
> |
19 |
>> I have no problem with what the above code is trying to achieve, just |
20 |
>> how it |
21 |
>> goes about doing so. At the very least, it shouldn't assume the |
22 |
>> existence of a |
23 |
>> procfs. |
24 |
>> |
25 |
>> If you do decide to handle your problem by checking the amount of |
26 |
>> RAM, please |
27 |
>> find an alternate way (obviously 'free' can't be used either) or at |
28 |
>> the very |
29 |
>> minimum check for file existence. |
30 |
> |
31 |
> Can you think of a nice portable way of doing this test? That would be |
32 |
> really helpful. |
33 |
|
34 |
Why not a sysctl call? as mentioned above, not all systems have /proc |
35 |
|
36 |
> |
37 |
> Duncan |
38 |
> |
39 |
> |
40 |
> -- |
41 |
> gentoo-dev@g.o mailing list |
42 |
> |
43 |
-----BEGIN PGP SIGNATURE----- |
44 |
Version: GnuPG v1.2.6 (Darwin) |
45 |
|
46 |
iD8DBQFBniGRJ0rMK/3OwgsRAgP6AJ9jUAxKFx8mpsP8EmGAcxcfvt488wCgmBLP |
47 |
Rpl5ifGSAaSZwBSr/+LEmMk= |
48 |
=N0Kj |
49 |
-----END PGP SIGNATURE----- |
50 |
|
51 |
|
52 |
-- |
53 |
gentoo-dev@g.o mailing list |