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 8619239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:17:40+00:00 2026-06-12T06:17:40+00:00

I developed a simple application with GTK+-2.0. My question is how can run a

  • 0

I developed a simple application with GTK+-2.0.
My question is how can run a bash script (for example with system(3)) without freezing program?
I tried to implement a thread system but it did not worked.

Here is my code snippet, I tried to simplify as good as I can.
Regards

int main(int argc,
    char * argv[])
{
    GtkWidget *button;


    /* init threads */  
    g_thread_init(NULL);
    gdk_threads_init();
    gtk_init(&argc,&argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    ...

    button = gtk_button_new_with_label("Format");
    g_signal_connect(button,"clicked",G_CALLBACK(callback),(gpointer)"button 1");
    gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1);
    gtk_widget_show(button);


        gdk_threads_enter();
    gtk_main();
    gdk_threads_leave();

    return 0;

}

/* Our callback.
* The data passed to this function is printed to stdout */
static void callback( GtkWidget *widget,
                  gpointer   data )
{
    int sTemp=0;
    GThread   *thread;
        GError    *error = NULL;
        g_print ("Hello again - %s was pressed\n", (char *) data);
        sTemp=ChecckIfFileExits("/dev/mmcblk0");
        if(sTemp)
        {
        gtk_label_set_text(GTK_LABEL(label),"Formatting");
        thread = g_thread_create( PFormatThrad, (gpointer)widget,
                          FALSE, &error );
        if( ! thread )
        {
            g_print( "Error: %s\n", error->message );

        }

    }
    else
    {
        g_print ("SD/MMC not found\n");
    }
}


static gpointer
PFormatThrad( gpointer data )
{

        sleep( 3 );

        gdk_threads_enter();

        system("./mkcard.txt /dev/mmcblk0");
    gtk_widget_set_sensitive(selectImageButton,TRUE);
    gtk_label_set_text(GTK_LABEL(label),"Format tamamlandı\nİmajı Seçin");
        gdk_threads_leave();

    return( NULL );
}    
  • 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-12T06:17:42+00:00Added an answer on June 12, 2026 at 6:17 am

    Don’t call fork() directly.

    It’s better, in a GTK+ application, to use glib’s process spawning API:s. For instance the g_spawn_async_with_pipes() function is very handy if you want to read the child process’ output.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to run a simple SQLITE application on Windows Mobile developed with
I have a question about deployment Java application in cloud. I've developed simple application
I have developed a simple application using SDK(Android: 3.2[API-13]) for, to display Google banners.
I developed one simple android application targeting the Mobiles with android 2.0 OS.I want
I am new to rails and have developed a simple rails application on my
On Windows 7, VB.NET Express, I have developed a simple Forms application. I don't
i developed a very simple vb.net application and i need a way for every
I have developed a simple location aware iPhone application which is functionally working very
I've developed a very simple ASP.NET (jQuery) application. The RDBMS is MS Sql Server
I have developed a simple application in GWT. After that, I generate war file

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.