I have written a C extension library for PG, using V1 calling convention. My db is ver 8.4. I have successfully created the new functions.
However, when I invoke my new functions, it crashes the server, with the following message sent to the console:
The connection to the server was lost. Attempting reset: Failed.
The server log contains the line:
server process (PID 14751) was terminated by signal 11: Segmentation fault
I want to attach gdb to the postgres process, and see if I can obtain a stack trace, to help me start debugging. However, when I run
ps aux | grep postgres
to try to locate the postgres process, there seems to be several processes called postgres.
How may I correctly identify the postgres server process (after restarted) for debugging purposes as described above?
I just found out the answer to this. The database name is also part of the ps aux output.
For example:
postgres 1071 0.0 0.1 101120 5360 ? S Jan03 0:01 /usr/lib/postgresql/8.4/bin/postgres -D /var/lib/postgresql/8.4/main -c config_file=/etc/postgresql/8.4/main/postgresql.conf
postgres 11866 0.0 0.1 68444 4340 pts/1 S+ 10:16 0:00 /usr/lib/postgresql/8.4/bin/psql postgres
postgres 14856 0.0 0.1 103612 4716 ? Ss 14:56 0:00 postgres: postgres mydatabase [local] idle
postgres 14894 0.0 0.0 101120 1640 ? Ss 15:05 0:00 postgres: writer process
The process id in this case is 14856