Search:

Type: Posts; User: Gatsu

Search: Search took 0.01 seconds.

  1. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    #include #include #include...

    #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>
  2. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    Hey guys, I had to make some changes and how come...

    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/ -...
  3. Replies
    5
    Views
    4,554

    nevermind, I discovered that if I used another...

    nevermind, I discovered that if I used another variable as a pointer it works :)

    thanks very much all!
  4. Replies
    5
    Views
    4,554

    So I have to use a pointer to the array so that...

    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:...
  5. Replies
    5
    Views
    4,554

    waitpid() in loop, not ending correctly

    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...
  6. Replies
    6
    Views
    1,288

    NEVERMIND!!! I found out that its because I did...

    NEVERMIND!!! I found out that its because I did not use fclose(fp)!! :) victory! :D thank you all very much for yout time
  7. Replies
    6
    Views
    1,288

    ok I pasted all my random lines togeather here: ...

    ok I pasted all my random lines togeather here:



    bash$ ./a.out file.txt
  8. Replies
    6
    Views
    1,288

    ok so I dig in to fprintf. I make a FILE like...

    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);
  9. Replies
    6
    Views
    1,288

    append to file with write()

    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:
  10. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    while(read(fd[0], &pipeBuffer[counter], 1) > 0) ...

    while(read(fd[0], &pipeBuffer[counter], 1) > 0)

    boooya!!

    thanks so much!!!! ^^
  11. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    I replaced sizeof(file) with number which is the...

    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...
  12. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    Ok thanks all I did a bit more googling and I...

    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;...
  13. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    there is only one method, the main method and its...

    there is only one method, the main method and its in first post, its whole program, I just left out the includes
  14. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    So I create the FILE: FILE *fp =...

    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:
  15. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    So, to write whats in the file to the pipe I have...

    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...
  16. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    adding like this? fd[0] = open(argv[1],...

    adding like this?

    fd[0] = open(argv[1], O_RDWR);
    fd[1] = open(argv[1], O_RDWR);

    it gave me:
  17. Thread: pipe

    by Gatsu
    Replies
    18
    Views
    2,374

    pipe

    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...
  18. Replies
    8
    Views
    1,416

    I think you missed that I ask about GROUP PID :P...

    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 :)
  19. Replies
    8
    Views
    1,416

    Thank you very much! I get it now, I made...

    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...
  20. Replies
    8
    Views
    1,416

    incrementing number

    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...
Results 1 to 20 of 20