Right now I have a program that executes another program and lets it run in the background. I want to know when the background process quits. I also want to know which background process quits, I...
Type: Posts; User: Schwarzhelm
Right now I have a program that executes another program and lets it run in the background. I want to know when the background process quits. I also want to know which background process quits, I...
I don't think my question was answered correctly. I don't want to wait because I want the program to run in the background, in this case the ps command. While it's running in the background I want...
I am having problems with running a child in the background. I want the child to run and then keep the parent active.
This is what keeps happening:
PID TTY TIME CMD
16844 pts/0 ...
Hello,
I'm trying to run a program via execlp and then fill it's input from another file.
Ideally it is going to mimic file<input. I've been playing with fgets and fgetc but I can't figure out...
Is there a way to get the output from running another command via execlp to output to a file?
Right now I am experimenting with fopen but I can't figure out what to do..
Any suggestions?
...
When I delcare command as static it hangs my program..... It appears to hang on the fgets. If I put a printf before it it will print but if I put one after it, it won't get there. Any Ideas?
...
Here is readCommandLine
char * readCommandLine()
{
char command[100];
char *p;
It still messes up... After my fork I lose the variable even when I try to print it, it prints a ?... any other suggestions?
Here's my main again with not as much stuff commented out... It may...
Sorry about all the commented code. I was trying to comment out all the calls to the other sub routines that I didn't post here. I also have been playing with the stuff around the fork to see if I...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
#include <time.h>
#include <sys/param.h>
That worked ... hmm that leaves me in a mess now.. ok it works if I define the variable directly like you did. hmm what could i be doing wrong?
The user inputs a commad and it holds until fork....
Isn't ls ls what I want? when I hard code ls in there then it works... again the variable is losing its value before it gets there
I just don't understand why it is losing its value ... I can...
I don't know if that's the issue.. when I print execCommand it comes up as ??'s.. it appears to lose it at the fork... anyway I delcared execCommand as a char by char * execCommand=malloc(100).
I...
After I fork I appear to lose my variable the first time I try to execute a program. It will run the 2nd, 3rd,.... time but not the first. Below is my code.
This is part of the shell code I am...
That still doesn't work ... and now it just prints
CPU Type: ???????VB
I think my sscanf order is fine... Like I said before it works fine if I print in my getCPUType sub, but when I try to...
I don't think the sscanf is my problem. If I print directly from my Get sub it works fine, but I don't want to to that. I want the information to be printed from my Main.
I'm sorry I guess I don't understand... could you please explain a little more..
thank you
Still no go.. I added a =malloc(100); in my code after the declarations. So my code in my main and bassically whereever else I had it written looks like this:
char* CPUType=malloc(100);
...
I keep having problems when I'm returning a string from my sub. It keeps printing:
CPU Type: Auth(????VB
CPU Model: AMD
when I print.
Here is my code:
char * GetCPUType()
{
I keep getting the error `GetCPUType' was previously implicitly declared to return `int'. I can't figure out what I'm doing wrong. Here is my code.
// this is in my main method.
printf("CPU...
I have buf declared as a char *buf. I tried the code that was suggested and it is still getting a segmentation fault. filename is dirp->d_name after a lstat.
Thank you.
if( S_ISLNK(mode) )
{
type = 'l'; /*symlink*/
readlink(fileName, buf, sizeof(buf));
printf("\n %s \n",buf);
}
I have a question about using macros in C.
First, I am trying to divide and return both the answer and the remainder from a macro. Right now I have:
#define DIVMOD(x,y,d,r) ((y)==0 ? d=0; r=0...