[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: point.jpg (19 KB, 515x217)
19 KB
19 KB JPG
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?
>>
>>106781038
You 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.
>>
>>106781245
you 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.
>>
>>106781038
release gpu resources?
>>
>>106781332
>as you understand the retardation of it
you mean that in a good or bad way?
because its retardedly simple
it boild down to a number
and ngl i like retard simple
>>
>>106781038
>program segfaults
>fire up gdb
>gdb segfaults
it's over
>>
>>106781393
run valgrind
gdb is like fprintf(stderr, "opisafaggot"), only in hex and everything's dumped at you at once
rly
idk why gdb
>>
>>106781393
>>106781434
also fprintf to stderr specifically bc its unbuffered then
so whenever the call happens, thats the exact moment it prints to terminal
>>
this is babby shit, g
im disappoint
also 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)
>>
>>106781393
you 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.
>>
>>106781038
To clean up? Close open files, sockets, free memory...
>>
>>106781357
read the limitations section on man 2 signalfd
it'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.
>>
>>106781526
oh 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 signalfd
what the fuck is this heresy
my immediate reaction to turning a signal into an fd
but then you can poll it with read so it actually makes sense
wtf
how can something be niggerlicious and absolutely briliant at the same time???

im reading it carefully gimme 5 mins
>>
>>106781570
good question. ask Linus.
>>
>>106781582
>its an abstraction
and thats the thing
when you deal with c you better go low level
linus said himself:
>the further you get from the kernel, the uglier the code gets
the primitives are rock solid
but theyre documented like fucking ass
fukken
niggervald. update your documentation for fucks sake
>>
>>106781582
>>106781636
i 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 strings
poorfags sse2 lmao
>>
>>106781663
and i did that bc its still simpler than intrinsics and shit
its not THAT performance critical
>>
>>106781636
btw, comments are not self aggrandizing
im documenting all the flaws of my code as i go, in the language that i use
>>
File: ai-lmao.png (294 KB, 821x656)
294 KB
294 KB PNG
marked as TODO so i can ctrl shift f in any ide with perfect portability etc
fukken superior work methods that add a multiplier to my output
fkn amateurs lamao
fukken
standardization and stramlining supremacy
efficiency total victory
even the laws of nature follow the principle of least action, as in- the EFFICIENT path
>>
>>106781663
>>106781679
>>106781763
cool anon. keep up the good work.
>>
>>106781999
checked
'doing my best, sir
>>
>>106781636
You can't just do array[-1] = '/' on a null-terminated char array in C.
>>
>>106781332
There's nothing annoying with normal signal handling. I swear to god modern programmers are so fucking retarded.
>>
>>106781636
Linux is a garbage codebase though
>>
>>106781038
It'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.
>>
>>106782519
of course i can
i even did
i 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_final
buffer_path_final[-1] gives me the last character before the null byte
i think its even the idiomatic way of doing things bc its portable

>>106783513
i have no opinion, never truly looked into it
it werks doe.
>>
>>106781038
if you're using SQLite your program is the database
>>
>>106781038
Its 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.
>>
>>106785634
though in practice forcing the client to retry is usually acceptable lol
>>
>>106781434
>why gdb
breakpoints
stack trace
printing memory areas
>>
>>106786227
idk, man
maybe when you profile the breakpoint comes in handy
otherwise valgrind gives a stack trace and you can printout memory areas in c
in fact, i always have debug printout functions to double check the algo itself, error catching etc etc when i code
>>
>>106786257
Valgrind it's pretty slow and that can make it harder to find out what's happening.
Gdb works better in threaded context.
>debug printout functions
with gdb you don't need, you can just set breakpoint and check the variables.
>>
>>106786310
i see
i get most of the functionality with my methods (like printout then exit instead of a breakpoint) but its clunkier
ill properly learn how to use gdb, you convinced me
>>
File: sleeping-processes.png (80 KB, 807x325)
80 KB
80 KB PNG
(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
>>
>>106781038
That 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.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

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.