Just wondering if anyone knows how to check if a process is running on Unix directly from a C program, and similarly, if its possible to establish the available and used space on a logical volume. I'm currently using an approach along these lines...
sprintf( SysCom, "ps -e|grep %s > tmpfile", ProcName );
system( SysCom );
stat( "tmpfile", &TmpFile );
if( TmpFile.st_size > 0 ).....
For the disk capacity, I pass a df -k command, redirected to a temp file, then read the token of the output which relates to the disk capacity back into a variable.
Making the program dependent on the OS like this is rather weak though, and I'm keen to find a more direct method if anyone knows of one.
Thanks in advance.