diff --git a/test_pam_goatherd.sh b/test_pam_goatherd.sh
index 0550324fbfdf3993e97befc6582946f0abaec246..04555ed7de1f6441effc742916b068fba89bb676 100644
--- a/test_pam_goatherd.sh
+++ b/test_pam_goatherd.sh
@@ -13,7 +13,7 @@ fi
 cleanup() {
     type start_pg_cleanup >/dev/null 2>/dev/null && start_pg_cleanup
 
-    pkill -u $USER goatherd
+    pkill -u $(whoami) goatherd
 }
 trap 'cleanup' EXIT INT