我已经什么都不懂了。我很感激你的帮助。提前谢谢。
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <pthread.h>
#include <interfacemanager.h>
using namespace std;
InterfaceManager IFACE;
void* watch_for_interfaces(void*)
{
IFACE.monitoring();
}
int main()
{
sigset_t *set;
sigemptyset(&(*set));
sigaddset(&(*set), SIGINT);
sigaddset(&(*set), SIGTERM);
pthread_t th1, th2;
int i=1;
if (pthread_create(&th2, NULL, watch_for_interfaces, (void*)&i) != 0) {
perror("th2 error\n");
exit(1);
}
printf ("Terminating\nPress eny key\n");
getchar();
exit(EXIT_SUCCESS);
return 0;
}
答案 0 :(得分:0)
问题不在于 sigset_t *set;
sigemptyset(&(*set));
sigaddset(&(*set), SIGINT);
sigaddset(&(*set), SIGTERM);
,而在于您的信号功能。
set
在这里,您使用的是未初始化的变量malloc
,并将其传递给 undefined 的信号函数。你可以 sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGINT);
sigaddset(&set, SIGTERM);
但是你必须把它写成
- (IBAction)ShareItem:(id)sender {
NSString *textToShare = @"This is just some random text I put here";
NSURL *myWebsite = [NSURL URLWithString:@"http://www.martylavender.com/"];
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Item"];
fetchRequest.resultType = NSDictionaryResultType;
NSError *error = nil;
NSArray *results = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
NSMutableArray *itemNames = [results valueForKey:@"itemname"];
NSString *names = [itemNames componentsJoinedByString:@" \n"];
NSLog(@"%@",names);
NSArray *objectsToShare = @[textToShare, myWebsite, names];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
NSArray *excludeActivities = @[UIActivityTypeAirDrop,
UIActivityTypePrint,
UIActivityTypePostToTwitter,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
[self presentViewController:activityVC animated:YES completion:nil];
}