[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I need all your advice on writing a daemon in C for macOS. I

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 25
Thread images: 4

File: 1497759704240.jpg (36KB, 600x489px) Image search: [Google]
1497759704240.jpg
36KB, 600x489px
I need all your advice on writing a daemon in C for macOS.

I have a network service which processes a packet, then exits. I wanted to use launchctld to run it again after it exits but that's not working out.
>>
>>60964231
>>>/pol/
>>
>>60964590
>t. doesn't even know what i'm talking about
>>
>>60964231
for (;;) {
network_service_which_processes_a_packet()
}
>>
File: checked.jpg (125KB, 526x1280px) Image search: [Google]
checked.jpg
125KB, 526x1280px
>>60964820
really? just wrap it in an infinite loop? and the os will be able to kill/exit/restart/launch the process cleanly if needed?
>>
File: chicken hug.gif (1MB, 360x360px) Image search: [Google]
chicken hug.gif
1MB, 360x360px
>>60964915
>>60964820
it really works
>>
>>60964915
>>60965115
My guess was right then. I don't know shit about apple apart from what I know about unix, but it makes sense that termination/exit is done by sending it SIGTERM. If you want to do it properly, you could also do something like
#include <signal.h>
int exit_flag = 0;
void sigterm_handler(int) { exit_flag = 1; }
int main(int argc, char **argv) {
signal(SIGTERM, sigterm_handler);
while (!exit_flag) {
process_packet();
}
}


Although you might want to use sigaction() instead of signal(), since the latter's implementations aren't consistent.
>>
Every single time statistics like that get actually checked by professionals, it turns out that they're just cherry-picked or missing the big picture. And more often than not, they're displayed in a way that's deceptive on purpose.
>>
>>60965264
yeah
>>
>>60965286
>posting an image of a url
Fucking dumbass, post something people can actually click
>>
>>60965286
If you do per 1,000,000 of the victim's race, the interracial murder bars flip. Also, this graph wasn't made by the FBI, nor was the "per 1,000,000" noted by the FBI either. The graph maker just Googled up us population statistics and stuck it in there.
>>
>>60965286
Yeah, right. Because I missed the huge and obvious source citation. You probably don't even know what I was getting at.
>>
>>60965340
Can you illustrate what you're saying? I don't see how that would change the significance of the graph.
>>
>>60965264
Don't see any listings of the number of unarmed white men shot by police versus the number of similar blacks shot by police.
The simple fact is that a policeman has little to fear if he shoots any black man. He will be very unlucky if he is held to account. Even less so if he is convicted.
He could probably even shoot Colin Powell and get away with it.
>>
Ah, the old bait and switch troll post.

Nicely executed, OP
>>
>>60965481
There is a large amount of white people. There is a small amount of black people.

If you divide something by number of white people, you get a small number. If you divide something by number of black people, you get a big number.

If you choose murder population to divide by:
black on white / black = big number
White on black / white = small number

If you choose victim population to divide by:
black on white / white = small number
white on black / black = big number

So which do you choose? Does black lives matter say "white people need to stop murdering!" or "black people are victims of crime!"
>>
>>60965206
so by using this, i can put any clean up inside the sigterm handler so that i can save states, or do whatever before exiting?
>>
>>60965605
yeah, well I'm Czech. I have nothing to do with slavery in america, yet black people are always harassing me, lumping me in with "white people". It's not convincing me to support blm.
>>
>>60964231
How come the latest statistic you have is 2013? Anything happen over the past 4 years you don't want people knowing about?
>>
>>60964590
>>>/lgbt/
>>
>>60965714
yeah, media doggedly hunting down any "white person" committing a crime they can find, ignoring the unrelenting stream of gang violence (they won't cover it) people on twitter "praying it's a white male" every time a terrorist attack happens, and the victim complex turning into the new form of currency in this dystopian future ruled by despotic talking heads in the media, not to mention the walls that enclose people by feeding them only more of what they posted about before instead of letting them have access to new information (facebook/ads, google)
>>
>>60965709
The FBI is who is lumping you in with white people though.
>>
ok, getting this back on track

what general advice do you have for writing a background process that just starts and requires no interaction? load it with launchd?
>>
>>60964820

>for (;;)
Why wouldn't you just do while (true)?
>>
>>60970195
for will break at a return

while means you have to set a flag
Thread posts: 25
Thread images: 4


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.