Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout to grep #20

Merged
merged 2 commits into from
Nov 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build-deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
sanji-bundle-route (0.9.6-1) unstable; urgency=low

* Add timeout to `grep` for preventing input without EOF.

-- Aeluin Chen <[email protected]> Thu, 05 Nov 2015 11:22:22 +0800

sanji-bundle-route (0.9.5-1) unstable; urgency=low

* Bugfix: default gateway cannot be updated at some scenario.
Expand Down
2 changes: 1 addition & 1 deletion bundle.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "route",
"version": "0.9.5",
"version": "0.9.6",
"author": "Aeluin Chen",
"email": "[email protected]",
"description": "Handle the routing table",
Expand Down
8 changes: 6 additions & 2 deletions ip/addr.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def ifupdown(iface, up):
if not up:
try:
output = sh.awk(
sh.grep(sh.grep(sh.ps("ax"), iface), "dhclient"),
sh.grep(
sh.grep(sh.ps("ax"), iface, _timeout=5),
"dhclient", _timeout=5),
"{print $1}")
dhclients = output().split()
for dhclient in dhclients:
Expand Down Expand Up @@ -150,7 +152,9 @@ def ifconfig(iface, dhcpc, ip="", netmask="24", gateway="", script=None):
# Disable the dhcp client and flush interface
try:
dhclients = sh.awk(
sh.grep(sh.grep(sh.ps("ax"), iface), "dhclient"),
sh.grep(
sh.grep(sh.ps("ax"), iface, _timeout=5),
"dhclient", _timeout=5),
"{print $1}")
dhclients = dhclients.split()
if 1 == len(dhclients):
Expand Down