The first point is almost trivial: your program's main function (assuming you are using
int main(int argc, char* argv)
receives the command to execute (e.g. "cat
and its parameters as
, etc... A very simple implementation would use the system
] call to execute the command.
The second point might be implemented, I guess, accessing the /proc/<pid>/stat