On Unix, all these three generate the same result
system("top -H -p $pid -n 1"); #ver1
system("top", "H", "p $pid", "n 1"); #ver2
system("top", "-H", "-p $pid", "-n 1"); #ver3
-
What is the difference between ver2 and ver3?
-
Is there any reason I should use ver2 and ver3, and not ver1?
-
They do not even support piping the results, for example, are there any ver2 and ver3 equivalents of the following call?
system("top -H -p $pid -n 1 | grep myprocess | wc -l");
Even it looks same it is not same:
It is up to
topimplementation that it works same. Other applications may not work same.