You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2003/10/16 01:58:21 UTC
[patch mod_example.c] print pid, ppid and tid
As I was debugging some weird behavior of mod_perl 2, where getppid() was
returning 1, I tried to verify that it works on the C level, using
mod_example.c. Do you think it's worth adding the following in mod_example.c?
It prints something like:
Process ID: 31870, Parent Process ID: 31864, Thread ID: 16384
Index: modules/experimental/mod_example.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_example.c,v
retrieving revision 1.41.2.1
diff -u -r1.41.2.1 mod_example.c
--- modules/experimental/mod_example.c 3 Feb 2003 17:31:37 -0000 1.41.2.1
+++ modules/experimental/mod_example.c 15 Oct 2003 23:56:33 -0000
@@ -75,6 +75,11 @@
#include "util_script.h"
#include "http_connection.h"
+#if APR_HAVE_UNISTD_H
+/* for getpid() */
+#include <unistd.h>
+#endif
+
#include "apr_strings.h"
#include <stdio.h>
@@ -580,6 +585,12 @@
ap_rputs(" <BR>\n", r);
ap_rprintf(r, " Server built: \"%s\"\n", ap_get_server_built());
ap_rputs(" </P>\n", r);;
+ ap_rprintf(r, "<P>Process ID: %lu, Parent Process ID: %lu",
+ (unsigned long)getpid(), (unsigned long)getppid());
+#if APR_HAS_THREADS
+ ap_rprintf(r, ", Thread ID: %lu", (unsigned long)apr_os_thread_current());
+#endif
+ ap_rputs(" </P>\n", r);
ap_rputs(" <P>\n", r);
ap_rputs(" The format for the callback trace is:\n", r);
ap_rputs(" </P>\n", r);
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: [patch mod_example.c] print pid, ppid and tid
Posted by Cliff Woolley <jw...@virginia.edu>.
On Wed, 15 Oct 2003, Stas Bekman wrote:
> +#if APR_HAVE_UNISTD_H
> +/* for getpid() */
> +#include <unistd.h>
> +#endif
> + ap_rprintf(r, "<P>Process ID: %lu, Parent Process ID: %lu",
> + (unsigned long)getpid(), (unsigned long)getppid());
> +#if APR_HAS_THREADS
> + ap_rprintf(r, ", Thread ID: %lu", (unsigned long)apr_os_thread_current());
> +#endif
Is there no truly portable way to do this?
--Cliff