Messages in this thread | | | Date | Tue, 4 May 1999 23:37:50 +0300 (EEST) | From | Yavuz Selim Komur <> | Subject | fork() Problem? |
| |
Hi, this problem maybe a gcc problem.
$ gcc -v Reading specs from /usr/lib/gcc-lib/i386-unknown-linux/egcs-2.91.66/specs gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
$ ls /lib/libc-* /lib/libc-2.1.so
kernel-2.2.7
--------------------------- Linux Output: Main Program pid: 10767 Main Program2 pid: 10767 Child Program pid: 10768 Ikinci bitti Yavuz 1
---------------------------- SunOs Output: Main Program pid: 18808 Child Program pid: 18809 Ikinci bitti Main Program2 pid: 18808 Segmentation fault
Source: ---------------------------------- #include <stdio.h>
struct dene { char adi[30]; struct dene *next; } *y, *q;
main() { int i=0, *status;
q = y = (struct dene *)malloc(sizeof(struct dene)); y->next = NULL; printf("Main Program pid: %i\n", getpid()); strcpy(y->adi, "Yavuz 1"); if(i = fork()) { printf("Main Program2 pid: %i\n", getpid()); wait(status); } else { printf("Child Program pid: %i\n", getpid()); strcat(y->adi, "Iki"); y->next = (struct dene *)malloc(sizeof(struct dene)); y = y->next; y->next = NULL; strcpy(y->adi, "Selim 2"); printf("Ikinci bitti\n"); return; } y = q; while(y) { printf("%s\n", y->adi); y = y->next; } return; } ----------------------------------------
Yavuz --------------------------- The FORCE will be with you.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |