#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
int main(int argc, char **argv) {
    int ret;
    int sum = 0;
    int status;
    for (int i = 1; i < argc; i++) {
        ret = fork();
        if (ret < 0) {
            perror("fork");
            exit(1);
        } else if (ret == 0) {
            int len = strlen(argv[i]);
            printf("I am child %d and I'm returning %d\n", i, len);
            exit(len);
        }
    }
    for (int i = 1; i < argc; i++) {
        if ((ret = wait(&status)) == -1) {
            perror("wait");
            exit(1);
        }
        if (WIFEXITED(status)) {
            sum += WEXITSTATUS(status);
        }
    }
    printf("The length of all the args is %d\n", sum);
    return 0;
}