Skip to content

Instantly share code, notes, and snippets.

@devendranaga
Created June 29, 2015 07:35
Show Gist options
  • Save devendranaga/ea1265fbf0534d4e2675 to your computer and use it in GitHub Desktop.
Save devendranaga/ea1265fbf0534d4e2675 to your computer and use it in GitHub Desktop.
calling exec in a pthread
#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