Re: periodically check if a service is running



Maybe you are looking for g_timeout_add function

http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-timeout-add


Regards

On 7/13/06, rupert <rupertt gmail com> wrote:

Hello,

imm trying to create a small window that shows me if a serice is running
and
displays a small icon that shows the status
i created this function that checks if a PID is there:

gint check_samba(){
    gint smb_pid2;
    gchar check_smb_cmd[512];
    sprintf(check_smb_cmd, "cat /var/run/samba/smbd.pid 2>/dev/null");
    //g_print("%s", check_smb_cmd);
    smb_pid2 = system(check_smb_cmd);
    //g_print("%s", smb_pid2);
    return smb_pid2;
}

the function is called here:

  gint smb_pid;
  smb_pid=check_samba();
  //g_print("PID: %i", smb_pid);
//while(1){
      if(smb_pid > 0)
      {
          image1 =  g_object_new(GTK_TYPE_IMAGE,"file",
"pics/ledgreen.png",
NULL);
      }else{
          image1 =  g_object_new(GTK_TYPE_IMAGE,"file", "pics/ledred.png",
NULL);
      }
  //}

  gtk_widget_show (image1);


So how can I check and if neccessary change the picture lets say every
each
2 seconds?
I thought i could use an endless while loop, but that didnt worked.
Also the PID gets displayes when I call the function, but a g_print("PID:
%i", smb_pid); give me (null)
has been quite a while since i worked with C, so this may be a dump error
by
me.

thx for your help
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]