3 Replies - 872 Views - Last Post: 21 October 2012 - 08:51 AM Rate Topic: -----

#1 jimmystocco  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 07-June 12

c incompatible pointer type shell

Posted 20 October 2012 - 03:19 PM

Hi guys!

I'm having problem with my code.. When I compile the code below, I get this warning:

funcoes.h: In function ‘runBgCommand’:
funcoes.h:175:3: warning: passing argument 2 of ‘signal’ from incompatible pointer type [enabled by default]
/usr/include/signal.h:101:23: note: expected ‘__sighandler_t’ but argument is of type ‘int *’

/**
  @brief Make a foreground process goes to background.
  @param pos_q_job is the job position on the process queue.
 */
void runBgCommand(int pos_q_job) 
{
        //queue is a global variable
	if(pos_q_job <= 50 && pos_q_job > 0)
	{
		signal(SIGSTOP,queue[pos_q_job-1].pid));
		queue[pos_q_job-1].status = "BG";
	}
}

This is my Queue structure:

typedef struct queue {
    int pos_q;
    char *status;
    char *command;
    int pid;
} Queue;


Does anyone knows how to fix this problem?

Thanks in advance!

This post has been edited by jimblumberg: 20 October 2012 - 03:24 PM
Reason for edit:: Added missing Code Tags, Please learn to use them.


Is This A Good Question/Topic? 0
  • +

Replies To: c incompatible pointer type shell

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 4075
  • View blog
  • Posts: 12,578
  • Joined: 25-December 09

Re: c incompatible pointer type shell

Posted 20 October 2012 - 03:27 PM

You need to pass the correct type of variable to the signal() function. It expects a sighandler_t not an int. You are trying to pass an int, Queue.pid. The sighandler_t is probably a structure of some sort, you may want to locate and study the documentation for the signal() function.

Jim
Was This Post Helpful? 0
  • +
  • -

#3 jimmystocco  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 07-June 12

Re: c incompatible pointer type shell

Posted 21 October 2012 - 08:41 AM

I've already declared <signal.h>, which is supposed to suport "sighandler_t", but I'm still having the same error.

Any idea?
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is offline

  • member icon


Reputation: 4075
  • View blog
  • Posts: 12,578
  • Joined: 25-December 09

Re: c incompatible pointer type shell

Posted 21 October 2012 - 08:51 AM

Don't try to pass anything but a sighandler_t type of variable as the second parameter to this function. An int is not a sighandler_t type.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1