Nope, not quite.
I was able to make a father process with more then one child by myself. But what I really want is after creating a number of child prcesses, starting with one of them as a father, it should again fork a few times, thus obtaing a tree-structure of processes.
So I guess I need some kind of recursive algorithm to do that. But here comes the problem: if I fork in a recursive way, I can't seem to get that tree structure right.
And also another problem: using the program shown by Perderabo and also my own, I changed the line:
printf("I am a child process and my pid is %d\n", getpid());
with this one:
printf("I am a child process id=%d father=%d\n",getpid(),getppid());
so I could see if the father is the right one, and after a few forks, all the child processes were generated by the process with pid=1. I avoided that by placing a sleep(2) command right before the end of the program, but I'm wondering: who's this process and is there another way to stop that?
Your post helped me out with a fork I am writing, but I am having a little trouble because the execve command only executes the "ls" command when i type one in - no matter WHAT command I type in. if i modify execve("/bin/ls", .....) to only read execve("/bin/", .....), it doesnt execute ANYTHING. what do i need to do? Here is my code:
We are not allowed to do your schoolwork for you. But I'll give you a few hints. Code like this:
Quote:
Originally posted by jj1814
is not going to run a "date" command. It's simply incredible that you think it might. execve is not going to ignore its arguments. You need to parse the command line and dynamically build arguments for the execve call.
And you should switch to execv anyway. As it is, you are clobbering the environment.
And, for now, require the user to enter "/usr/bin/date" rather than "date" so you don't need to search the PATH. You can get fancy later.
Compiling with g++ on an OpenBSD 3.0 box, I get a "Memory Fault", and it dumps core when I try to run a command, like "ls".
The exit value is 139, and gdb reports a "Program received signal SIGSEGV, Segmentation fault.
0x1ad8 in main () "
Is this machine specific?
(I'm a no-C / C++ goof - Trying, though)
I just downloaded the code and works for me on Sun. I don't see anything machine specific here. He is not testing for too many arguments and, if you entered 20 or more arguments to that ls, you could get a memory fault. Could that be it?
I am writing a bash script to automate the installation of web environment on a base install of Fedora. And I'm at the limit of my last nerve and my bash skills. My brain is screaming at me: "Give up and use perl", but I am trying to stick to bash since the script will modify the perl environment... (6 Replies)
I have a file that is 20 - 80+ MB in size that is a certain type of log file.
It logs one of our processes and this process is multi-threaded. Therefore the log file is kind of a mess. Here's an example:
The logfile looks like: "DATE TIME - THREAD ID - Details", and a new file is created... (4 Replies)
I don't want to speak about the goods or bads of both kinds of Operating systems, I only want to share a little experience with you to comment it.
I live in Spain and I have home some old unix systems, some of them that I want to sell or change for other things, like a pair of Sun Blade 2000... (0 Replies)
I've been able to generate output based on the code scarfake provided me (thanks again man).
A little background so everyone more or less knows whats going on:
I needed code that would propagate a database with 100,000 entries, for capacity testing purposes, something like a stress test.
... (5 Replies)
Hi everyone,
I have a requirement that requires me to fill an sqlite database with 100,000 entries (no duplicates).
I will start out by giving the command that will insert the values necessary to populate the database:
# sqlite /var/local/database/dblist "insert into list... (2 Replies)
I've just installed redhat 6.2 on one of my systems and am trying to install the gcc c compiler after downloading an rpm from the redhat site. The damn thing gives me:
only major numbers <= 3 are supported by this version of RPM
what do I do, it does the same with the latest rpm of php
... (7 Replies)