@@ -379,6 +379,17 @@ func runWithName(name string) error {
379379 // ALWAYS return the same port for (directory, name) - port is stable per directory
380380 if existing := store .FindByDirectoryAndName (cwd , name ); existing != nil {
381381 debug .Printf ("main" , "found existing allocation for name %s: port %d (locked=%v)" , name , existing .Port , existing .Locked )
382+
383+ // Warn if the port is busy (occupied by another process)
384+ if ! port .IsPortFree (existing .Port ) {
385+ procInfo := port .GetPortProcess (existing .Port )
386+ if procInfo != nil && procInfo .Name != "" {
387+ fmt .Fprintf (os .Stderr , "warning: port %d is busy (%s); use --forget to get a new port\n " , existing .Port , procInfo .Name )
388+ } else {
389+ fmt .Fprintf (os .Stderr , "warning: port %d is busy; use --forget to get a new port\n " , existing .Port )
390+ }
391+ }
392+
382393 // Update last_used timestamp for the specific port being issued
383394 if ! store .UpdateLastUsedByPort (existing .Port ) {
384395 debug .Printf ("main" , "warning: UpdateLastUsedByPort failed for port %d" , existing .Port )
@@ -798,18 +809,7 @@ func runList() error {
798809 maxDirLen := 0
799810
800811 for i , alloc := range allAllocs {
801- directory := alloc .Directory
802-
803- // Check if port is busy and has Docker info
804- if ! port .IsPortFree (alloc .Port ) {
805- if procInfo := port .GetPortProcess (alloc .Port ); procInfo != nil {
806- if procInfo .ContainerID != "" && procInfo .Cwd != "" && procInfo .Cwd != "/" {
807- directory = procInfo .Cwd
808- }
809- }
810- }
811-
812- shortDir := pathutil .ShortenHomePath (directory )
812+ shortDir := pathutil .ShortenHomePath (alloc .Directory )
813813 allDirectories [i ] = shortDir
814814
815815 if len (shortDir ) > maxDirLen {
@@ -828,7 +828,6 @@ func runList() error {
828828 username := "-"
829829 pid := "-"
830830 process := "-"
831- directory := alloc .Directory
832831
833832 // Determine SOURCE and use saved external info for external allocations
834833 source := "free"
@@ -874,20 +873,12 @@ func runList() error {
874873 } else if procInfo .ContainerID != "" {
875874 // Docker container detected via fallback
876875 process = "docker-proxy"
877- if procInfo .Cwd != "" && procInfo .Cwd != "/" {
878- directory = procInfo .Cwd
879- }
880876 } else {
881877 // Have user but no PID and no Docker - mark incomplete only if no saved name
882878 if alloc .ProcessName == "" {
883879 hasIncompleteInfo = true
884880 }
885881 }
886-
887- // Use live Docker directory if available and better than saved
888- if procInfo .ContainerID != "" && procInfo .Cwd != "" && procInfo .Cwd != "/" {
889- directory = procInfo .Cwd
890- }
891882 }
892883 }
893884
@@ -903,10 +894,6 @@ func runList() error {
903894
904895 // Get pre-calculated directory string and truncate if needed
905896 shortDir := allDirectories [i ]
906- // If directory was updated by Docker check, re-shorten it
907- if directory != alloc .Directory {
908- shortDir = pathutil .ShortenHomePath (directory )
909- }
910897 // Cap at 40 characters maximum
911898 if len (shortDir ) > maxDirWidth {
912899 shortDir = truncateDirectoryPath (shortDir , maxDirWidth )
0 commit comments