cURL / Mailing Lists / curl-users / Single Mail

curl-users

cURL processes hanging when run via a system call

From: Chris Tata <chris_at_softwareprojects.com>
Date: Tue, 14 Feb 2006 15:00:55 -0500

Hello,

I am having a problem with cURL being called via a 'system' command in
an ANSI C program. Here is the code that is executed:

sprintf(scmd, "/usr/local/bin/curl -G -s -k -m 120 -d \"%s\"
http://remote-ip/myscript.php -L > %s", buffer, outfile);
system(scmd);

This code is executed 1000's of times in a loop per daemon iteration.
The command is successful around 95% of the time, but on occasion hangs
indefinitely. Looking at the process status I see these 2 processes:

78833 ?? I 0:00.01 sh -c /usr/local/bin/curl -G -s -k -m 120 -d
"account_id=103&user_id=0&name=US&description="
http://remote-ip/myscript.php
78834 ?? R 33:47.68 /usr/local/bin/curl -G -s -k -m 120 -d
account_id=103&user_id=0&name=US&description= http://remote-ip/myscript.php

Adding a 'u' flag to ps shows that PID 78834 is using 98% CPU:

root 78834 97.9 0.1 2968 1088 ?? R 6:58PM 33:37.41
/usr/local/bin/curl -G -s -k -m 120 -d account_id=103&user_id=0&name=
root 78833 0.0 0.0 632 228 ?? I 6:58PM 0:00.01 sh -c
/usr/local/bin/curl -G -s -k -m 120 -d "account_id=103&user_id

This process will hang indefinitely until I kill it and is always
utilizing 98% CPU. This behavior, right off the bat, is strange since I
am using the -m flag with 120 seconds. It will continue to hang for
hours and hours. Once I 'kill -9' the process, my program will either
segfault or continue to run (depending on what side of the bed it woke
up on that day) for sometimes an hour, sometimes a day, but eventually
will run into the hanging cURL process which causes my program to hang
again. The remote script is written to just return a number (eg.
342434) if that matters.

Here is my cURL and OS version info:

curl 7.15.1 (i386-portbld-freebsd4.7) libcurl/7.15.1 OpenSSL/0.9.7i
zlib/1.1.4
Protocols: tftp ftp gopher telnet dict ldap http file https ftps
Features: Largefile NTLM SSL libz

FreeBSD tracking 4.7-RELEASE-p28 FreeBSD 4.7-RELEASE-p28 #42: Tue Jun 21
10:33:20 MDT 2005 root_at_fc2:/usr/src/sys/compile/VKERN i386 (this is
one of those shared virtual servers..yay)

Although it probably won't help in assessing the cause of cURL hanging,
I was able to grab a stack trace during a bad hair day:

Program received signal SIGKILL, Killed.
0x281c34b0 in wait4 () from /usr/lib/libc.so.4
(gdb) bt
#0 0x281c34b0 in wait4 () from /usr/lib/libc.so.4
#1 0x2819e946 in system () from /usr/lib/libc.so.4
#2 0x804f117 in HitsSourceAdd ()
#3 0x804a916 in ProcessTrafficByLine ()
#4 0x80496a3 in ProcessTraffic ()
#5 0x80492f5 in main ()
#6 0x80491c9 in _start ()
(gdb)

Would switching to the cURL C API help me out here any? Any help would
be very appreciated. I have been banging my head on this one for a few
weeks now :)

Thanks,
Chris

Received on 2006-02-14