Find the answer to your Linux question:
Results 1 to 7 of 7
Hi, How we can call a c program from a driver? Can we use system() for this? Thanks...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Nov 2011
    Posts
    68

    how to call a c pgm from driver


    Hi,
    How we can call a c program from a driver? Can we use system() for this?

    Thanks

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,664
    From a driver? Not easily, since the driver is running in kernel-space and a program has to run in user-space. Please explain, in gory detail, what EXACTLY you are trying to accomplish?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Nov 2011
    Posts
    68
    We have a gpio driver with interrupt handler .If some interrupt is coming it will go to interrupt handler , from that interrupt handler i want to call a C program which will take picture.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,664
    Sorry, but I don't think you can do that. You need to signal a running user-space program that can do that for you. In any case, you NEVER want to do anything that takes more than microseconds in an interrupt handler. You set some flags, return from the handler (freeing the interrupt controller as a result), and then do stuff that is more time consuming. In any case, you still will not want to do this in the driver. So, have a daemon program running that the driver can signal. When the daemon gets the signal, it can then take the picture, and do whatever you need with it. In any case you absolutely CANNOT run executable programs from the kernel using system() or exec...() functions. Start reading up on kernel module development, because it is clear to me that you are still pretty clueless. Not to case aspersions on you or your development skills, but kernel development work is highly specialized, with a lot of rules that do not apply to normal software, and until you learn those rules, you are treading in dangerous waters!
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #5
    Just Joined!
    Join Date
    Nov 2011
    Posts
    68
    Thanks for your reply. How a driver can signal daemon program and call other c program? I am new to this field so dont have much idea.

  7. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,664
    Quote Originally Posted by steffi View Post
    Thanks for your reply. How a driver can signal daemon program and call other c program? I am new to this field so dont have much idea.
    Sorry, but I don't have time to give you kernel programming lessons. However, there are means for kernel modules to raise signals in user-space programs. You daemon process can have an appropriate signal handler that will intercept the raised signal, and it can then use a system() call to execute the appropriate program.

    FWIW, I have recently (at the beginning of the year) started a new position as Senior Systems/Performance Engineer at Nokia, so most of my spare time is taken up with analyzing a few million lines of Java, Javascript, C++, and other code, along with designing new SNMP system/network management framework tools... Time is something that I have little of right now. They hired me because we are growing the division from 1-5M users now, to 50M in a year, and 100M in 2 years. I'm running as fast as I can...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  8. #7
    Just Joined!
    Join Date
    Nov 2011
    Posts
    68
    Its k ....Thanks....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •