Name

mysql_list_processes( )

Synopsis

MYSQL_RES *mysql_list_processes(MYSQL *mysql)

This returns a results set containing a list of MySQL server processes or server threads found for the handle given as the argument to the function.

...
result = mysql_list_processes(mysql);
while((row = mysql_fetch_row(result)) != NULL)
  {
   printf("Thread ID: %s \n", row[0]);
   printf("User: %s, Host: %s \n", row[1], row[2]);
   printf("Database: %s, Command: %s \n", row[3], row[4]);
   printf("Time: %s, State: %s, Info: %s \n\n",
          row[5],row[6],row[7]);
  }
mysql_free_result(result);
...

Using the mysql_fetch_row() function, each row of the results set is read and each field displayed with its related label. The results are the same as the SHOW PROCESSES query in MySQL. It’s important to run the mysql_free_result( ) function when finished with a results set, as shown here.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.