Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h> /* perror printf */
- #include <stdlib.h> /* free exit */
- #include <fcntl.h> /* open */
- #include <unistd.h> /* chdir fchdir */
- #include <sys/stat.h> /* stat */
- #include <dirent.h> /* DIR */
- #include <sys/statvfs.h> /* statvfs */
- #include <string.h> /* strlen strcat strcpy */
- #include <stdarg.h> /* for printf ovveride */
- #include <sys/wait.h>
- #include <sys/mman.h>
- #include <dlfcn.h>
- /*VARIABLES*/
- /* -------------VARIABLES*/
- int main ( int argc, char *argv[] )
- {
- int i;
- int st;
- void *dl;
- void *dl2;
- for(i = 1; i < argc; i++)
- {
- pid_t child_a, child_b, rv;
- child_a = fork();
- if (child_a == 0)
- {
- dl = dlopen(argv[i], RTLD_LAZY | RTLD_LOCAL );
- if( dl == NULL ){
- puts( dlerror() );
- exit(1);
- }
- printf("PID: %lu PPID: %lu - vaikas: %s\n", getpid(), getppid(), argv[i]);
- rv = wait( &st );
- }
- else
- {
- child_b = fork();
- if (child_b == 0)
- {
- dl2 = dlopen(argv[i], RTLD_LAZY | RTLD_LOCAL );
- if( dl2 == NULL ){
- puts( dlerror() );
- exit(1);
- }
- printf("PID: %lu PPID: %lu - vaikas: %s\n", getpid(), getppid(), argv[i]);
- rv = wait( &st );
- }
- else
- {
- /*printf("Parent PID = %ld\n", (long)getpid());*/
- printf("PID: %lu - tevo procesas\n", getpid());
- }
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement