From 0e670f13ccc8aefcb79750e43ec33d0795703927 Mon Sep 17 00:00:00 2001 From: Andre MARQUEZ Date: Tue, 25 Jul 2017 18:50:39 +0200 Subject: [PATCH] added script --- close_port.sh | 41 +++++++++++++++++++++++++++++++++++++++++ src/server/main.c | 6 +++--- 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100755 close_port.sh diff --git a/close_port.sh b/close_port.sh new file mode 100755 index 0000000..87efdcc --- /dev/null +++ b/close_port.sh @@ -0,0 +1,41 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# close_port.sh :+: :+: :+: # +# +:+ +:+ +:+ # +# By: amarquez +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2017/07/25 18:06:36 by amarquez #+# #+# # +# Updated: 2017/07/25 18:50:15 by amarquez ### ########.fr # +# # +# **************************************************************************** # + +## number pattern + +re='^[0-9]+$' + +## ask for port number + +printf "PORT #: "; + +## assign port number + +read -p "" port + +## check if valid port number + +if [ "$port" -eq "$port" ] 2>/dev/null; then + + # get output from lsof ( including PID ) + + lsof="$(lsof -i :$port)" + + printf "$lsof"; + +else + + # not a valid port number + + printf "error: not a valid port number"; + +fi diff --git a/src/server/main.c b/src/server/main.c index 4a386aa..67b9ee6 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -60,7 +60,7 @@ int main(int argc, char **argv) ** initialize environment with variables we want */ - ft_init_environ(); +// ft_init_environ(); /* ** close to prevent zombies @@ -84,7 +84,7 @@ int main(int argc, char **argv) } #ifndef __APPLE__ - ft_free_environ(); +// ft_free_environ(); #endif /* ** kill the process @@ -100,4 +100,4 @@ int main(int argc, char **argv) ft_wclose(connfd); } return (0); -} \ No newline at end of file +}