X-Git-Url: https://git.piment-noir.org/?p=TD_SE.git;a=blobdiff_plain;f=thread-pid%2Fthread-pid.c;fp=thread-pid%2Fthread-pid.c;h=a993c777d5a11766f3f8ba3c3482be840e1bc6f2;hp=0000000000000000000000000000000000000000;hb=dfdf4860c5feca46d1647bf602e8701db1660216;hpb=80b410a1b65f72042bae86be2ea9656196a0a0ff diff --git a/thread-pid/thread-pid.c b/thread-pid/thread-pid.c new file mode 100644 index 0000000..a993c77 --- /dev/null +++ b/thread-pid/thread-pid.c @@ -0,0 +1,18 @@ +#include // pour sleep +#include // pthread_create, pthread_join, pthread_exit +#include + +static void* fonction(void* args) { + printf("pid du thread fils = %d\n", getpid()); + while(1); // forever + return NULL; +} + +int main() { + pthread_t thread; + + printf("pid de main = %d\n", getpid()); + pthread_create(&thread, NULL, &fonction, NULL); + while(1); // forever + return 0; +}