Skip to content

Fix log noise on Linux devices without WiFi: dynamic interface discovery in MachineInfoProvider#147

Merged
nnhy merged 2 commits into
masterfrom
copilot/fix-linux-no-wifi-log-noise
Jul 20, 2026
Merged

Fix log noise on Linux devices without WiFi: dynamic interface discovery in MachineInfoProvider#147
nnhy merged 2 commits into
masterfrom
copilot/fix-linux-no-wifi-log-noise

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

On Linux machines without a wireless NIC, MachineInfoProvider.Refresh() unconditionally spawned iw dev wlan0 link on every heartbeat, causing command failed: No such device (-19) to flood logs via inherited stderr.

Changes

  • Dynamic wireless interface discovery (MachineInfoProvider.cs): Replace hardcoded wlan0 with NetworkInterface.GetAllNetworkInterfaces() filtered to Wireless80211 + Up. When no wireless interfaces exist the list is empty, the loop is skipped entirely, and iw is never spawned. Also supports non-standard names (wlp2s0, wlan1, etc.) and multiple interfaces.
// Before
var rs = Execute("iw", "dev wlan0 link", 1_000);

// After
var wirelessInterfaces = NetworkInterface.GetAllNetworkInterfaces()
    .Where(e => e.NetworkInterfaceType == NetworkInterfaceType.Wireless80211
                && e.OperationalStatus == OperationalStatus.Up)
    .Select(e => e.Name)
    .ToList();

foreach (var ifName in wirelessInterfaces)
{
    var linkOutput = Execute("iw", $"dev {ifName} link", 1_000);
    // ... parse SSID / signal, break on first non-zero signal
}
  • Redirect stderr (Execute helper): Enable RedirectStandardError = true so any residual child-process stderr is captured rather than inherited by the StarAgent process.

- 使用 NetworkInterface.GetAllNetworkInterfaces() 动态查找无线网卡,
  兼容 wlan0/wlp2s0/wlan1 等各种命名,无 WiFi 设备时跳过 iw 进程启动
- 启用 RedirectStandardError = true,彻底避免子进程 stderr 污染日志

Closes #146
Copilot AI changed the title [WIP] Fix log noise from MachineInfoProvider on Linux without WiFi device Fix log noise on Linux devices without WiFi: dynamic interface discovery in MachineInfoProvider Jul 20, 2026
Copilot finished work on behalf of nnhy July 20, 2026 11:28
Copilot AI requested a review from nnhy July 20, 2026 11:28
@nnhy
nnhy marked this pull request as ready for review July 20, 2026 11:32
Copilot AI review requested due to automatic review settings July 20, 2026 11:32
@nnhy
nnhy merged commit 9285c87 into master Jul 20, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces log noise and unnecessary process spawning on Linux devices without WiFi by discovering wireless interfaces dynamically (instead of hardcoding wlan0) and by redirecting child-process stderr to prevent it from being inherited by the agent process.

Changes:

  • Discover wireless interfaces at runtime via NetworkInterface.GetAllNetworkInterfaces() and query iw dev <if> link only for matching interfaces.
  • Enable RedirectStandardError = true in the Execute helper to avoid stderr leaking into parent logs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 299 to 303
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
//RedirectStandardError = true,
RedirectStandardError = true,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Linux 无 WiFi 设备时 MachineInfoProvider 频繁输出 'command failed: No such device (-19)' 日志噪音

3 participants