This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

system call issue

Hi,

I am using RDK03.00.00.00 and I find sometimes when I use system call, it will have error message "sh: out of file descriptors" or "sh: write error: Invalid argument".

Is there anyone know this ?

  • Are you refering to C library "system" function call ? If so then we have seen the issue and unfortunately there is no solution. My understanding is system function causes a fork of the process and doing fork after application does Syslink_setup() will cause system to run out of memory. We have modified DVR RDK to avoid all calls to "system" for this reason. Can you avoid calling system() in your app.

  • Hi Badri,

    Thanks for your quickly reply. Do you mean we can't use any system call in this platform ? Even we write an another simple program to do system call,  and it will have the same issue ?

  • Hi Badri,
       We also need your confirm about the restriction when using system call. Thanks

  • Can you confirm you are refering to C lib system function and not linux kernel system call. The workaround if you want to use "system()" function that I can think of is to have a separate app running that does the system() invocation and communicate to that app from the main RDK  app by using some unix IPC mechanism. This way the main RDK app will not get forked. You could also try forking this separate app as a process before you call Syslink_setup in the main app and check if you still see the issue. Other option if possible is to avoid calling system() by doing the same operation by some other means but that depends on what you want to do.For example we were using system() function to echo to sysfs entries but we avoided that and instead directly opened file handle to sysfs entries and wrote to it. Refer Vdis_sysfsCmd for reference

  • Hi Badri,
    Can you confirm you are refering to C lib system function and not linux kernel system call.
    -By checking, we use C lib because of stdlib.h. Right?

    The workaround if you want to use "system()" function that I can think of is to have a separate app running that does the system() invocation and communicate to that app from the main RDK  app by using some unix IPC mechanism.
    -Did you mean to cretae another process?

  • Can you confirm you are refering to C lib system function and not linux kernel system call. 
    -By checking, we use C lib because of stdlib.h. Right?

     - I mean does your app have code like 

       system("echo Hello");

    -Did you mean to cretae another process?

      - Yes create another process or have a separate app.If you create another process do it before Syslink_setup.Then to send system cmds from main app send cmds to this other app via some unix InterProcessCommunication mechanism and invoke the actual system() from the other process.

  • Hi Badri,

    I create an another app and run it before Syslink_setup and repeat to do system call like "killall("app1"); sleep(3); system("app1 &"); sleep(3)". It still has "sh: write error: Invalid argument" after it runs several times.

  • Can you confirm : You have a separate app. This simple app just invokes some system command. And that is failing ? Pls share the code for this app. I want to try it out in my setup.

  • I find my dvr_rdk_mcfw_api still has some system call and I fix it. Then, I can run it without sh error after 10 times, but I have another issue which is "Too many open files". It should not be full quickly even I forget to close the file descriptor. 

  • Can you check the cat /proc/<pid>/fd and see the number of open file handles.

  • / # cat /proc/1045/fd/
    0 10 12 14 16 18 2 21 23 25 3 5 7 9
    1 11 13 15 17 19 20 22 24 26 4 6 8

  • This does not seem to be issue with too many open file handles. You can confirm by checking ulimit -a and check the limit on file handles.I think it should be 1024 by default.

    Maybe some other error is occuring and error msg is wrong. Pls share the full console logs from bootup onwards to when you face the issue.