lua script is crashing linux side

For checking if Yun is in Wifi range i'm using this lua script:

#!/usr/bin/lua

local function get_wifi_info(network, iface, accumulator)
  local net = network:get_wifinet(iface)

  if net then
    local dev = net:get_device()
    if dev then
      accumulator["quality"] = net:signal_percent()
    end
  end
end

local function collect_wifi_info()
  local network = require"luci.model.network".init()
  local accumulator = {}
  get_wifi_info(network, "wlan0", accumulator)
  return accumulator
end

local info = collect_wifi_info()

if info.quality then
  print(info.quality)
end

It is giving back the signalstrength of wifi.

At the sketch side im using this code:

boolean wifiConnected() {
  String strength;
  
  Process p;        // Create a process and call it "p"
  p.runShellCommand("/mnt/sda1/wifi-status.lua");
  p.run();      // Run the process and wait for its termination

  while (p.available()>0) {
    char c = p.read();
    strength += c;
  }
  // Ensure the last bit of data is sent.
  Serial.flush();

  #ifdef debug
  Serial.println("Wifi Signalstaerke: " + strength);
  #endif

  if (strength == "") {
    
    return false;
  }  
  if (strength.toInt() > 0) {
      return true;
  }
  else {
    return false;
  }    
}

It's giving back TRUE if signalstrenght is more then zero.

Im using this in loop to decide, if yun should upload data or store data in file. After a while, sometimes hours, the hole yun is blocking. The white led, who is showing if wifi is ok, is going off and i can not access yun anymore until i reset it.

What could be going wrong? Thank's for some ideas.

The RunShellCommand method already executes the command, you don't need to call run(). I'd replace it with

Process p;
p.begin("/mnt/sda1/wifi-status.lua");
p.run();

Other things seem fine to me.

Thank's for the advice. I removed the RunShellCommand.

For 2 weeks of testing it worked well. But today i got the same proplem. Executing the lua script is crashing linux side.

Maybee someone knows the reason.

cello:
Thank's for the advice. I removed the RunShellCommand.

For 2 weeks of testing it worked well. But today i got the same proplem. Executing the lua script is crashing linux side.

Maybee someone knows the reason.

cello,
This line does not look syntactically correct.
Jesse

  local network = require"luci.model.network".init()