Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 460462
Collapse All | Expand All

(-)src/preferences.h (+1 lines)
Lines 24-29 Link Here
24
#define ACTIONS_FILE          "parcellite/actions"
24
#define ACTIONS_FILE          "parcellite/actions"
25
#define FIFO_FILE_C          "parcellite/fifo_c"
25
#define FIFO_FILE_C          "parcellite/fifo_c"
26
#define FIFO_FILE_P          "parcellite/fifo_p"
26
#define FIFO_FILE_P          "parcellite/fifo_p"
27
#define PID_FILE             "parcellite/daemon.pid"
27
#define PREFERENCES_FILE      "parcellite/parcelliterc"
28
#define PREFERENCES_FILE      "parcellite/parcelliterc"
28
29
29
/*struct pref_item* get_pref(char *name); */
30
/*struct pref_item* get_pref(char *name); */
(-)src/main.c (-3 / +21 lines)
Lines 24-29 Link Here
24
#include <config.h>
24
#include <config.h>
25
#endif
25
#endif
26
26
27
#include <errno.h>
28
#include <sys/file.h>
29
27
#include "parcellite.h"
30
#include "parcellite.h"
28
31
29
32
Lines 388-394 Link Here
388
{ 
391
{ 
389
	if(NULL != appindicator_process && !have_appindicator ){
392
	if(NULL != appindicator_process && !have_appindicator ){
390
		g_printf("Looking for '%s'\n",appindicator_process);
393
		g_printf("Looking for '%s'\n",appindicator_process);
391
		if(proc_find(appindicator_process,PROC_MODE_STRSTR,NULL) >0){
394
		if(proc_find(appindicator_process,NULL) >0){
392
			have_appindicator=1;
395
			have_appindicator=1;
393
			if(NULL == indicator && show_icon)
396
			if(NULL == indicator && show_icon)
394
				create_app_indicator();	
397
				create_app_indicator();	
Lines 1899-1905 Link Here
1899
{
1902
{
1900
	struct cmdline_opts *opts;
1903
	struct cmdline_opts *opts;
1901
	int mode;
1904
	int mode;
1902
	
1905
    gboolean is_first_instance = FALSE;
1906
1907
    /* PID file creation */
1908
    check_dirs();
1909
    if (!flock(open(g_build_filename(g_get_user_data_dir(), PID_FILE, NULL), O_CREAT | O_RDWR, 0640), LOCK_EX | LOCK_NB))
1910
        is_first_instance = TRUE;
1911
    else
1912
    {
1913
        if (errno != EWOULDBLOCK)
1914
        {
1915
            perror("unable to check running instances");
1916
            return 1;
1917
        }
1918
    }
1919
1903
  bindtextdomain(GETTEXT_PACKAGE, PARCELLITELOCALEDIR);
1920
  bindtextdomain(GETTEXT_PACKAGE, PARCELLITELOCALEDIR);
1904
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
1921
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
1905
  textdomain(GETTEXT_PACKAGE);
1922
  textdomain(GETTEXT_PACKAGE);
Lines 1911-1917 Link Here
1911
	opts=parse_options(argc, argv);
1928
	opts=parse_options(argc, argv);
1912
  if(NULL == opts)
1929
  if(NULL == opts)
1913
   	return 1;
1930
   	return 1;
1914
	if(proc_find(PARCELLITE_PROG_NAME,PROC_MODE_EXACT,NULL)<2)	/**1 for me, and 1 for a running instance  */
1931
    if(is_first_instance)
1915
		mode=PROG_MODE_DAEMON; /**first instance  */
1932
		mode=PROG_MODE_DAEMON; /**first instance  */
1916
	else
1933
	else
1917
		mode=PROG_MODE_CLIENT; /**already running, just access fifos & exit.  */
1934
		mode=PROG_MODE_CLIENT; /**already running, just access fifos & exit.  */
Lines 1943-1948 Link Here
1943
			
1960
			
1944
	  }  else if(opts->clipboard){
1961
	  }  else if(opts->clipboard){
1945
			fifo=init_fifo(FIFO_MODE_CLI|mode);
1962
			fifo=init_fifo(FIFO_MODE_CLI|mode);
1963
			if(fifo->dbg) g_printf("Hit CLI opt!\n");
1946
			
1964
			
1947
			if(PROG_MODE_CLIENT & mode){
1965
			if(PROG_MODE_CLIENT & mode){
1948
				if(NULL != opts->leftovers){
1966
				if(NULL != opts->leftovers){
(-)src/utils.h (-1 / +1 lines)
Lines 62-68 Link Here
62
	gint which;	/**which clipboard the buffer should be written to  */
62
	gint which;	/**which clipboard the buffer should be written to  */
63
	gint dbg;		/**set to debug fifo system  */
63
	gint dbg;		/**set to debug fifo system  */
64
};
64
};
65
int proc_find(const char* name, int mode, pid_t *pid);
65
int proc_find(const char* name, pid_t *pid);
66
int create_fifo(void);
66
int create_fifo(void);
67
int open_fifos(struct p_fifo *fifo);
67
int open_fifos(struct p_fifo *fifo);
68
int read_fifo(struct p_fifo *f, int which);
68
int read_fifo(struct p_fifo *f, int which);
(-)src/utils.c (-17 / +7 lines)
Lines 184-190 Link Here
184
\n\b Arguments:
184
\n\b Arguments:
185
\n\b Returns:	number of instances of name found
185
\n\b Returns:	number of instances of name found
186
****************************************************************************/
186
****************************************************************************/
187
int proc_find(const char* name, int mode, pid_t *pid) 
187
int proc_find(const char* name, pid_t *pid) 
188
{
188
{
189
	DIR* dir;
189
	DIR* dir;
190
	FILE* fp;
190
	FILE* fp;
Lines 210-231 Link Here
210
210
211
    if ((fp= fopen(buf, "r"))) {
211
    if ((fp= fopen(buf, "r"))) {
212
      if (fgets(buf, sizeof(buf), fp) != NULL) {
212
      if (fgets(buf, sizeof(buf), fp) != NULL) {
213
				if(PROC_MODE_EXACT == mode){
213
            if(NULL !=g_strrstr(buf,name)){
214
					gchar *b=g_path_get_basename(buf);
214
                ++instances;
215
		      if (!g_strcmp0(b, name)) {
215
                if(NULL !=pid)
216
						++instances;
216
                  *pid=lpid;
217
						if(NULL !=pid)
217
                /*g_printf("Looking for '%s', found '%s'\n",name,buf); */
218
						  *pid=lpid;
218
            }
219
		      }
220
				}else if( PROC_MODE_STRSTR == mode){
221
					if(NULL !=g_strrstr(buf,name)){
222
						++instances;
223
						if(NULL !=pid)
224
						  *pid=lpid;
225
						/*g_printf("Looking for '%s', found '%s'\n",name,buf); */
226
					}
227
				}
228
				
229
      }
219
      }
230
      fclose(fp);
220
      fclose(fp);
231
    }
221
    }

Return to bug 460462