is there any point in trying to capture SIGKILL or SIGTERM in most programs? or is it just wankery unless you are a database or something like that?
>>106781038You can’t catch SIGKILL btw
Catching SIGTERM is good for graceful closing of what you're doing. Like you finish all buffered IO and then close or something.
>>106781245you can. just spoof your name and anything you do is inside a fork
You can't catch sigkill, you should just use signalfd as long as you understand the retardation of it, because it makes signal handling a lot less annoying desu.
>>106781038release gpu resources?
>>106781332>as you understand the retardation of ityou mean that in a good or bad way?because its retardedly simpleit boild down to a numberand ngl i like retard simple
>>106781038>program segfaults>fire up gdb>gdb segfaultsit's over
>>106781393run valgrindgdb is like fprintf(stderr, "opisafaggot"), only in hex and everything's dumped at you at oncerlyidk why gdb
>>106781393>>106781434also fprintf to stderr specifically bc its unbuffered thenso whenever the call happens, thats the exact moment it prints to terminal
this is babby shit, gim disappointalso valgrind bc it overallocates and it more or less sandboxes (it has to, in order to analyze the spaghetti, if it goes out of bounds)
>>106781393you joke, but this happened to me a lot trying to debug arm binaries from x86. literal humiliation ritual. same when the debugger gives up and just dumps you into instruction by instruction asm because it loses track of where it was.
>>106781038To clean up? Close open files, sockets, free memory...
>>106781357read the limitations section on man 2 signalfdit's really fucking annoying honestly.most people set up a self-pipe system because of this. I think there was attempts at a v2 signalfd, but people were so butthurt by how bad v1 is it never got worked on.
>>106781526oh and ya.... read the "semantics" paragraphs too.the epoll one, fork one, etc. it's really fucking insane just how retarded it is. I usually don't go out of my way to spawn chilluns so it doesn't matter when i use it, but you may use other code that does.the problem ultimately is even in other code, can said code set up its own signal handling that fucks your shit up too. really signals are fucking stupid. I really wish we had something like Window's message queues.gl anon.
>>106781526>man 2 signalfdwhat the fuck is this heresymy immediate reaction to turning a signal into an fdbut then you can poll it with read so it actually makes sensewtfhow can something be niggerlicious and absolutely briliant at the same time???im reading it carefully gimme 5 mins
>>106781570good question. ask Linus.
>>106781582>its an abstractionand thats the thingwhen you deal with c you better go low levellinus said himself:>the further you get from the kernel, the uglier the code getsthe primitives are rock solidbut theyre documented like fucking assfukkenniggervald. update your documentation for fucks sake
>>106781582>>106781636i did that to guarantee a buffer bc of an acceleration in the algo (i treat 8 chars at a time. basically perfectly portable sse2 at the cost of overallocating 7 bytes to your c stringspoorfags sse2 lmao
>>106781663and i did that bc its still simpler than intrinsics and shitits not THAT performance critical
>>106781636btw, comments are not self aggrandizingim documenting all the flaws of my code as i go, in the language that i use
marked as TODO so i can ctrl shift f in any ide with perfect portability etcfukken superior work methods that add a multiplier to my outputfkn amateurs lamaofukkenstandardization and stramlining supremacyefficiency total victoryeven the laws of nature follow the principle of least action, as in- the EFFICIENT path
>>106781663>>106781679>>106781763cool anon. keep up the good work.
>>106781999checked'doing my best, sir
>>106781636You can't just do array[-1] = '/' on a null-terminated char array in C.
>>106781332There's nothing annoying with normal signal handling. I swear to god modern programmers are so fucking retarded.
>>106781636Linux is a garbage codebase though
>>106781038It's good for things you want saved before the program bows out, like the contents of a document, or the progress in a game. If you're writing tools vs full pieces of software (e.g. software gadgets like calculators) then I wouldn't bother.
>>106782519of course i cani even didi check if there is a path to begin with just above (if i didnt i could have seg'd when checking a -1 index)stpcpy returns a pointer to the null byte which i put into buffer_path_finalbuffer_path_final[-1] gives me the last character before the null bytei think its even the idiomatic way of doing things bc its portable>>106783513i have no opinion, never truly looked into itit werks doe.
>>106781038if you're using SQLite your program is the database
>>106781038Its important for basically any server, as you can use it to say "stop accepting any new requests/connections, but finish up any existing ones within a time limit" instead of just dropping everything on the floor and making all of your clients retry.This is really important for high availability and zero-downtime upgrades, since you can remove a server/container as a load-balancer target, SIGINT it, start the new version, and add it back it, rinse-and-repeat, without any disruption to your users.
>>106785634though in practice forcing the client to retry is usually acceptable lol
>>106781434>why gdbbreakpointsstack traceprinting memory areas
>>106786227idk, manmaybe when you profile the breakpoint comes in handyotherwise valgrind gives a stack trace and you can printout memory areas in cin fact, i always have debug printout functions to double check the algo itself, error catching etc etc when i code
>>106786257Valgrind it's pretty slow and that can make it harder to find out what's happening. Gdb works better in threaded context.>debug printout functionswith gdb you don't need, you can just set breakpoint and check the variables.
>>106786310i seei get most of the functionality with my methods (like printout then exit instead of a breakpoint) but its clunkierill properly learn how to use gdb, you convinced me
(Wake me up)Wake me up inside(I can't wake up)Wake me up inside(Save me)Call my name and save me from the dark
>>106781038That obviously depends on what the program is doing and whether anything could end up corrupted or stuck in some form of bad / invalid state if not turned off properly. For example if it's writing into a file that needs to be in some sort of format in order to be valid, then you would probably want to flush buffers and make sure the file is correct before you close it. If it's talking to some hardware directly, maybe it's necessary to put it in some particular state before closing and so on.In many other programs it may not be necessary.