2003-03-16 10:59:17 +08:00
|
|
|
#include "system.h"
|
2003-03-16 05:51:11 +08:00
|
|
|
|
2003-03-16 10:59:17 +08:00
|
|
|
#include <pthread.h>
|
2003-03-16 05:51:11 +08:00
|
|
|
|
2007-10-28 13:11:57 +08:00
|
|
|
#include "rpmsq.h"
|
2003-03-17 06:36:52 +08:00
|
|
|
#include <popt.h>
|
2003-03-16 10:59:17 +08:00
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
2003-03-16 05:51:11 +08:00
|
|
|
static void *
|
|
|
|
other_thread(void *dat)
|
|
|
|
{
|
2003-03-17 06:36:52 +08:00
|
|
|
const char * cmd = (const char *)dat;
|
|
|
|
const char ** av = NULL;
|
|
|
|
int ac = 0;
|
|
|
|
int xx = poptParseArgvString(cmd, &ac, &av);
|
|
|
|
if (xx)
|
|
|
|
return ((void *)xx);
|
|
|
|
fprintf(stderr, "thread(%lu): pid %u %s\n", pthread_self(), getpid(), cmd);
|
|
|
|
return ((void *) rpmsqExecve(av));
|
2003-03-16 05:51:11 +08:00
|
|
|
}
|
2003-03-16 00:56:46 +08:00
|
|
|
|
2003-03-16 05:51:11 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2003-03-16 10:59:17 +08:00
|
|
|
pthread_t pth;
|
2003-03-17 06:36:52 +08:00
|
|
|
const char * cmd = argv[1];
|
2003-03-16 00:56:46 +08:00
|
|
|
|
2003-03-17 06:36:52 +08:00
|
|
|
if (cmd == NULL)
|
|
|
|
cmd = "/bin/sleep 30";
|
|
|
|
pthread_create(&pth, NULL, other_thread, (void *)cmd);
|
|
|
|
fprintf(stderr, " main(%lu): pid %u other(%lu)\n", pthread_self(), getpid(), pth);
|
2003-03-16 00:56:46 +08:00
|
|
|
|
2003-03-16 10:59:17 +08:00
|
|
|
sleep(2);
|
|
|
|
pthread_cancel(pth);
|
2003-03-16 00:56:46 +08:00
|
|
|
|
2003-03-16 10:59:17 +08:00
|
|
|
pthread_join(pth, NULL);
|
|
|
|
return 0;
|
2003-03-16 00:56:46 +08:00
|
|
|
}
|