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

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.

...

>t. doesn't even know what i'm talking about

for (;;) {
network_service_which_processes_a_packet()
}

really? just wrap it in an infinite loop? and the os will be able to kill/exit/restart/launch the process cleanly if needed?

it really works

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
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.

yeah

>posting an image of a url
Fucking dumbass, post something people can actually click

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.

Yeah, right. Because I missed the huge and obvious source citation. You probably don't even know what I was getting at.

Can you illustrate what you're saying? I don't see how that would change the significance of the graph.

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

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!"

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?

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.

How come the latest statistic you have is 2013? Anything happen over the past 4 years you don't want people knowing about?

...

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)

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?

>for (;;)
Why wouldn't you just do while (true)?

for will break at a return

while means you have to set a flag