Re: [DNG] How to test the backend of simple-netaid
Hi KatolaZ, On 19/3/19 11:13, KatolaZ wrote: On Tue, Mar 19, 2019 at 11:00:59AM +0100, aitor_czr wrote: [cut] I answer myself, referring to the use of pkill wpa_supplicant: #include int kill_wpa_supplicant(void) { pid_t wpa_pid; FILE *fp; fp = (fopen("/var/run/wpa_supplicant.pid", "r")); if (fp == NULL) { printf("Couldn't read Wpasupplicant pid file, not trying to kill."); return 0; aitor, please notice that the pid file for wpa_supplicant can be literally*anywhere*. At the moment, in Devuan Beowulf, it is stored in the folder/var/run/wpa_supplicant/. But this is just very unreliable, IMHO. Please also consider that `wpa_supplicant(8)` has an option "-P" that allows to specify the path to pidfile... My2Cents KatolaZ The following code does the job: #include #include #include #include int main() { char *pid, output[1024]; FILE *fp = popen ( "pidof wpa_supplicant", "r" ); fgets ( output, 1024, fp ); fclose ( fp ); pid = strtok ( output, " " ); while( pid ) { pid_t wpa_pid=atoi ( pid ); if ( ( kill ( wpa_pid, SIGTERM ) ) == 0) return 0; else { kill ( wpa_pid, SIGKILL ); // Still alive? Die! return 0; } pid = strtok ( NULL , " " ); } } Analogous to the following bash script, used in the "kill-all-dhcp" of netcfg (but extended to all the dhcp clients): #!/bin/sh # Killall for dhcp clients. for client in dhclient udhcpc pump dhcp6c; do pid=$(pidof $client) || true [ "$pid" ] || continue echo $pid if kill -0 $pid 2>/dev/null; then kill -TERM $pid sleep 1 # Still alive? Die! if kill -0 $pid 2>/dev/null; then kill -KILL $pid fi fi done Cheers, Aitor. ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] How to test the backend of simple-netaid
Il 20/03/19 09:16, Dr. Nikolaus Klepp ha scritto: > Anno domini 2019 Tue, 19 Mar 23:55:36 +0100 > KatolaZ scripsit: >> On Tue, Mar 19, 2019 at 11:41:16PM +0100, aitor_czr wrote: >> >> [cut] >> >>> fsmithred wrote the following command in d1g time ago: >>> >>> |kill $(ps -e |grep wpa |grep -oP '\d{3,}') >>> https://dev1galaxy.org/viewtopic.php?id=2158 Aitor. | >>> >> >> Maybe something like: >> >> $ kill -9 $(pidof wpa_supplicant) >> >> is easier to use ;) pidof(8) is still there. >> >> My2Cents >> >> KatolaZ >> > killall -9 wpa_supplicant > > ;-) THOU SHALL NOT KILL -9! https://unix.stackexchange.com/questions/28572/when-you-try-to-terminate-a-process-for-good-which-option-for-kill-should-you#28578 -- Alessandro Selli VOIP SIP: dhatarat...@ekiga.net Chiave firma e cifratura PGP/GPG signing and encoding key: BA651E4050DDFC31E17384BABCE7BD1A1B0DF2AE signature.asc Description: OpenPGP digital signature ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] How to test the backend of simple-netaid
On Wednesday, 20th of March at 10:22, KatolaZ wrote: On Wed, Mar 20, 2019 at 09:16:17AM +0100, Dr. Nikolaus Klepp wrote: [cut] > > > Maybe something like: > > $ kill -9 $(pidof wpa_supplicant) > > is easier to use ;) pidof(8) is still there. > > My2Cents > > KatolaZ > killall -9 wpa_supplicant ;-) Sure. The main difference is that killall is in psmisc, which is "Priority: optional", while pidof is in sysvinit-utils, which is "Priority: required" in Devuan ;) HND KatolaZ I mostly just use "pkill" (from the procps package). It seems there are many tools to kill unwanted processes... :^) - Antoine -- Two things are infinite: the universe and human stupidity. ...though we're not entirely sure about the universe. ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] How to test the backend of simple-netaid
On Wed, Mar 20, 2019 at 09:16:17AM +0100, Dr. Nikolaus Klepp wrote: [cut] > > > > > > Maybe something like: > > > > $ kill -9 $(pidof wpa_supplicant) > > > > is easier to use ;) pidof(8) is still there. > > > > My2Cents > > > > KatolaZ > > > > killall -9 wpa_supplicant > > ;-) Sure. The main difference is that killall is in psmisc, which is "Priority: optional", while pidof is in sysvinit-utils, which is "Priority: required" in Devuan ;) HND KatolaZ -- [ ~.,_ Enzo Nicosia aka KatolaZ - Devuan -- Freaknet Medialab ] [ "+. katolaz [at] freaknet.org --- katolaz [at] yahoo.it ] [ @) http://kalos.mine.nu --- Devuan GNU + Linux User ] [ @@) http://maths.qmul.ac.uk/~vnicosia -- GPG: 0B5F062F ] [ (@@@) Twitter: @KatolaZ - skype: katolaz -- github: KatolaZ ] signature.asc Description: PGP signature ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
Re: [DNG] How to test the backend of simple-netaid
Anno domini 2019 Tue, 19 Mar 23:55:36 +0100 KatolaZ scripsit: > On Tue, Mar 19, 2019 at 11:41:16PM +0100, aitor_czr wrote: > > [cut] > > > > > fsmithred wrote the following command in d1g time ago: > > > > |kill $(ps -e |grep wpa |grep -oP '\d{3,}') > > https://dev1galaxy.org/viewtopic.php?id=2158 Aitor. | > > > > > Maybe something like: > > $ kill -9 $(pidof wpa_supplicant) > > is easier to use ;) pidof(8) is still there. > > My2Cents > > KatolaZ > killall -9 wpa_supplicant ;-) -- Please do not email me anything that you are not comfortable also sharing with the NSA, CIA ... ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng