Created
June 29, 2015 07:35
-
-
Save devendranaga/ea1265fbf0534d4e2675 to your computer and use it in GitHub Desktop.
calling exec in a pthread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <pthread.h> | |
void *thread_func(void *data) | |
{ | |
execlp("/bin/ls", "ls", "-l", NULL); | |
} | |
int main(void) { | |
int ret; | |
pthread_t tid; | |
ret = pthread_create(&tid, NULL, thread_func, NULL); | |
if (ret < 0) { | |
return -1; | |
} | |
while (1) { | |
printf(".... \n"); | |
sleep(1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment