一个主界面上面有控件,点击控件之后出现一个脱离主界面的运用程序,然后将主界面杀死
#include
#include
#include
void *job(void *arg)
{
printf("%s %d: pid = %d, self = %p\n", __func__, __LINE__, getpid(), pthread_self());
pthread_detach(pthread_self());
int papid = getpid();
system("./1");
int ret = kill(papid, SIGKILL);
if(ret)
{
printf("kill failled");
}
return NULL;
}
int main(void)
{
pthread_t tid;
int ret;
ret = pthread_create(&tid, NULL, job, NULL);
if (ret < 0)
{
perror("pthread_create");
return -1;
}
printf("%s %d: pid = %d, self = %p\n", __func__, __LINE__, getpid(), pthread_self());
printf("%s %d: tid = %p\n", __func__, __LINE__, tid);
ret = pthread_equal(tid, pthread_self());
if (ret == 0)
{
printf("tid is not current thread!\n");
}
pthread_join(tid, NULL);
return 0;
}
-----------------------------------------------------------------------------------
#include
int main(void)
{
while(1)
{
printf("Hello");
}
return 0;
}
-------------------------------------------------------------------------------------
while(1)
{
printf("Hello");
sleep(1);
}
阅读(1022) | 评论(1) | 转发(0) |