I am writing a C++ program on a POSIX compliant OS. I know many shells have "jobs" command that provide these services, but my program is in c++ and there is no specific "jobs" command that I could use. Any way around it?
I guess next time you should post in the Windows Programming forum. You can run a system command (if Windows has one) and redirect the output to a file, then open the file and parse it.
Well, my computer is using Windows but I am writing the program in a Linux environment (using putty i was able to gain access to my school's linux server). It is a c++ program btw. Anyways, i looked into the ps command, and I don't think it could work in this situation.
Why not? The ps command lists running processes. You can even get a list of all processes besides your own. Can you explain why it wouldn't work for you?
my program reads command line input, and parses the input in order to interpret the first token. The user must input the keyword "jobs" in order to list all the processes that are running in the background (actually just the process ids). So I would need something like,
1 2
if(strcmp(argv[0], "jobs") == 0)
ps
but the ps is undefined as is indicated by the g++ upon compilation.
Well, commands are not directly executed as the input is put into an array and upon "jobs" input i have to implement some system call that would list all the currently running processes. This is much harder than I thought.