#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
Type: Posts; User: Gatsu
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
Hey guys, I had to make some changes and how come this always returns 0 characters if I do like this in the parent:
[C] #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ -...
nevermind, I discovered that if I used another variable as a pointer it works :)
thanks very much all!
So I have to use a pointer to the array so that all children add to the same array?
creating array like this:
int *childPid[5];
when child is created, add to this array like this:...
Hi, I have a small program that will fork 5 children and after the last child is created dispose of them one atthe time in a loop like this:
for(x = 0 ; x < 5 ; x++)
{
int waitValue...
NEVERMIND!!! I found out that its because I did not use fclose(fp)!! :) victory! :D thank you all very much for yout time
ok I pasted all my random lines togeather here:
bash$ ./a.out file.txt
ok so I dig in to fprintf.
I make a FILE like this:
FILE *fp = fopen(argv[1], "a+"); //read and append
And append the file with this:
fprintf(fp, "\n\n%d", number);
Hi!
I have an array with two digits:
int digits[2];
dprintf(digits, "%d", number);
Now I want to append those digits to my textfile:
while(read(fd[0], &pipeBuffer[counter], 1) > 0)
boooya!!
thanks so much!!!! ^^
I replaced sizeof(file) with number which is the amount of characters in the textfile and check what write returns:
You may see the full code here:
[C] #include <unistd.h> #include...
Ok thanks all I did a bit more googling and I came up with this:
the parent does this (read file to array and send to pipe):
char file[1024];
FILE *fp = fopen(argv[1], "r");
int q;...
there is only one method, the main method and its in first post, its whole program, I just left out the includes
So I create the FILE:
FILE *fp = fopen(argv[1], "r");
And another array for it:
char fileA[1024];
Make a loop to read all characters in it:
So, to write whats in the file to the pipe I have to make a FILE and use fopen and maybe fscan to stuff the file contents in another array that I can send to the pipe?
I would like if there is...
adding like this?
fd[0] = open(argv[1], O_RDWR);
fd[1] = open(argv[1], O_RDWR);
it gave me:
Hello, so im trying to make a pipe that use child and parent for reading/writing.
I have a textfile which i get from the argument argv[1], the parent reads and send every character in the file to...
I think you missed that I ask about GROUP PID :P thanks anyway bro, that was usefull information even if I didnt need it atm :)
Thank you very much! I get it now, I made everything much more simple by just using the for loop and checking value of i because it increments :cool:
Is it normal that the child's group PID is the...
Hi, im forking 3 times in a loop like this but the variable "count" does not increment, it stays on '1' and therefore this is an infinite loop, and this simple thing dont make sense to me, some extra...