Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:34:33+00:00 2026-06-17T08:34:33+00:00

It’s been forever since I’ve used C so I apologize for the simple question.

  • 0

It’s been forever since I’ve used C so I apologize for the simple question.

I’m working with GPIO on a armeabi-v7a device. I need to export the GPIO interface into userspace from within an android app and I am trying to do so from a JNI library.

To do this from the terminal I would just run echo 199 > /sys/class/gpio/export

But I need to do it from JNI 🙁

My current attempt looks like this (with some error handling), but does not work:

JNIEXPORT jboolean JNICALL Java_com_rnd_touchpanel_LED_exportGreen
    (JNIEnv * je, jclass jc)
{
    freopen("/sys/class/gpio/export", "w+", stdout);
    printf("198");
    fclose(stdout);
    return JNI_TRUE;
}

I then realized that export is actually binary not just a file, and I’ve forgotten how to spawn new processes and send them input and all that. Could someone refresh my memory? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:34:34+00:00Added an answer on June 17, 2026 at 8:34 am

    If you’re just writing a file, there’s no need to redirect stdout — just open the file with fopen(3), write to it with fprintf(3), and close it with fclose(3).

    If you need to execute another process with given data on its standard, you have a few options:

    • Use system(3) to invoke the shell and give it your desired redirections
    • Use popen(3) with type "w" and fprintf your data to the returned FILE*
    • Use fork(2) and exec*(3) to spawn the new process. After forking but before exec’ing, use pipe(2), dup2(2) and close(2) to setup the new process’s stdin appropriately. You can then write to that file descriptor from the parent process to setup the data. This is the most complicated option, but it gives you the most control over how the child process is setup.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
In my XML file chapters tag has more chapter tag.i need to display chapters
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.