Re: Error in my C programming
On Sunday 20 February 2005 11:02 am, Kathy Quinlan wrote: > Peter Jeremy wrote: > > On Mon, 2005-Feb-21 00:22:56 +0800, Kathy Quinlan wrote: > >>These are some of the errors I get in pairs for each of the above > >> variables: > >> > >>Wtrend_Drivers.c:15: conflicting types for `Receiver' > >>Wtrend_Drivers.h:9: previous declaration of `Receiver' > > > > Without knowing exactly what is on those lines, it's difficult to > > offer any concrete suggestions. > > > > Two possible ways forward: > > 1) Change the declaration at Wtrend_Drivers.h:9 to be 'extern' > > 2) Pre-process the source and have a close look at the definitions > > and declarations for Receiver. You may have a stray #define that > > is confusing the type or a missing semicolon. > > > > Peter > > Here is a section of my code: > > *** Wtrend_Drivers.c *** > > (12)void Reset_Network (unsigned char Network) > (13) { > (14)Length = 0x00; > (15)Receiver = 0x00; > (16)Node = 0xFF; > (17)Command = Reset; > (18)Make_Packet_Send(Head , Length, Network, Receiver, Node, > Command, p_Data); > (19) } > > *** Wtrend_Drivers.h *** > > unsigned char Length , Network , Receiver , Node , Command = 0x00; > > The above is line 9 of the Wtrend_Drivers.h > The numbers in () I have added to show the line numbers in > Wtrend_Drivers.c > > These are some of the errors I get in pairs for each of the above > variables: > > Wtrend_Drivers.c:15: conflicting types for `Receiver' > Wtrend_Drivers.h:9: previous declaration of `Receiver' > > Regards, > > Kat. How does it do when you use decimal equivalents? (14)Length = 0; (15)Receiver = 0; (16)Node = 255; -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Error in my C programming
On Sunday 20 February 2005 11:48 am, Kathy Quinlan wrote: > Gary Corcoran wrote: > > Kathy Quinlan wrote: > >> Peter Jeremy wrote: > >>> On Mon, 2005-Feb-21 00:22:56 +0800, Kathy Quinlan wrote: > These are some of the errors I get in pairs for each of the > above variables: > > Wtrend_Drivers.c:15: conflicting types for `Receiver' > Wtrend_Drivers.h:9: previous declaration of `Receiver' > >>> > >>> Without knowing exactly what is on those lines, it's difficult to > >>> offer any concrete suggestions. > >>> > >>> Two possible ways forward: > >>> 1) Change the declaration at Wtrend_Drivers.h:9 to be 'extern' > >>> 2) Pre-process the source and have a close look at the > >>> definitions and declarations for Receiver. You may have a stray > >>> #define that is confusing the type or a missing semicolon. > >>> > >>> Peter > >> > >> Here is a section of my code: > >> > >> *** Wtrend_Drivers.c *** > >> > >> (12)void Reset_Network (unsigned char Network) > >> (13) { > >> (14)Length = 0x00; > >> (15)Receiver = 0x00; > >> (16)Node = 0xFF; > >> (17)Command = Reset; > >> (18)Make_Packet_Send(Head , Length, Network, Receiver, Node, > >> Command, p_Data); > >> (19) } > >> > >> *** Wtrend_Drivers.h *** > >> > >> unsigned char Length , Network , Receiver , Node , Command = 0x00; > >> > >> The above is line 9 of the Wtrend_Drivers.h > >> The numbers in () I have added to show the line numbers in > >> Wtrend_Drivers.c > >> > >> These are some of the errors I get in pairs for each of the above > >> variables: > >> > >> Wtrend_Drivers.c:15: conflicting types for `Receiver' > >> Wtrend_Drivers.h:9: previous declaration of `Receiver' > > > > I would try putting the variables in the header file on separate > > lines. For example: > > > > unsigned char Length = 0; > > unsigned char Network = 0; > > unsigned char Receiver = 0; > > etc. > > Done that to no avail :( > > Regards, > > Kat. I wonder if Receiver is defined in a include file elsewhere? I checked all the header files on my system and it isn't, perhaps it is on your though? Maybe easier to rename it? Here is what I did to hunt for it: find /usr/include | xargs grep Receiver > log find /usr/local/include | xargs grep Receiver >> log find /usr/X11R6/include | xargs grep Receiver >> log -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Error in my C programming
On Sunday 20 February 2005 12:41 pm, Richard Sharpe wrote: > On Sun, 20 Feb 2005, Michael C. Shultz wrote: > > > >> Here is a section of my code: > > > >> > > > >> *** Wtrend_Drivers.c *** > > > >> > > > >> (12)void Reset_Network (unsigned char Network) > > > >> (13) { > > > >> (14)Length = 0x00; > > > >> (15)Receiver = 0x00; > > > >> (16)Node = 0xFF; > > > >> (17)Command = Reset; > > > >> (18)Make_Packet_Send(Head , Length, Network, Receiver, > > > >> Node, Command, p_Data); > > > >> (19) } > > > >> > > > >> *** Wtrend_Drivers.h *** > > > >> > > > >> unsigned char Length , Network , Receiver , Node , Command = > > > >> 0x00; > > > >> > > > >> The above is line 9 of the Wtrend_Drivers.h > > > >> The numbers in () I have added to show the line numbers in > > > >> Wtrend_Drivers.c > > > >> > > > >> These are some of the errors I get in pairs for each of the > > > >> above variables: > > > >> > > > >> Wtrend_Drivers.c:15: conflicting types for `Receiver' > > > >> Wtrend_Drivers.h:9: previous declaration of `Receiver' > > > > > > > > I would try putting the variables in the header file on > > > > separate lines. For example: > > > > > > > > unsigned char Length = 0; > > > > unsigned char Network = 0; > > > > unsigned char Receiver = 0; > > > > etc. > > > > > > Done that to no avail :( > > > > > > Regards, > > > > > > Kat. > > > > I wonder if Receiver is defined in a include file elsewhere? I > > checked all the header files on my system and it isn't, perhaps it > > is on your though? Maybe easier to rename it? > > However, the error messages point out that the conflicting definition > is where Receiver is first used in the function in the .c file. If it > was another definition, we would be told of the actual .h file where > the definition came from. I have seen that lots of times :-) > > Regards Your right. We do not have enough of her code. I tried this: #include unsigned char Receiver = 0; int main(void) { Receiver = 0x00; printf( "Receiver -=>%c\n", Receiver ); return(0); } compiled it with: gcc -W -Wall -ansi -pedantic -Wbad-function-cast -Wcast-align \ -Wcast-qual -Wchar-subscripts -Winline \ -Wmissing-prototypes -Wnested-externs -Wpointer-arith \ -Wredundant-decls -Wshadow -Wstrict-prototypes zz.c -o zz and no warnings -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: cvsup can't work
On Monday 14 March 2005 06:33 pm, wanakahalugi wrote: > hi all, > > I installed FreeBSD5.3REL on my PC, and I want to update the source > tree and ports collection using cvsup. > To do that I copy the stable-supfile to /etc directory and set its > default host tag to the nearest mirror, and also set only the ports > that I want to update to save bandwith. > Everything is work fine except when I run the command # cvsup > /etc/stable-supfile the response from the mirror server is like this > : > > [EMAIL PROTECTED] root]# cvsup /etc/stable-supfile > Cannot connect to cvsup.id.FreeBSD.org: Connection refused > Will retry at 09:31:28 > > I use netstat to look what happen inside those error message, and I > found this one : > > [EMAIL PROTECTED] cakra]$ netstat > Active Internet connections > Proto Recv-Q Send-Q Local Address Foreign Address > (state) tcp4 0 0 192.100.40.14.53875 > mirror.cbn.net.i.cvsup SYN_SENT > > The PC never ESTABLISHED the connection to the server it's only do > the SYN_SENT. Why it happen? Is cvsup using certain ports so I can > make some proper change on my firewall? > ___ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to > "[EMAIL PROTECTED]" It uses port 5999 see /etc/services -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
threads question
Hi, I've just reached a point in a program I'm writing where I'd like to do threading. When I try to start a thread like this: pthread_create(&thread, &attr, MGPMrUpgrade, property ); where property is a structure of many variables it doesn't get passed to the function. If I do this: pthread_create(&thread, &attr, MGPMrUpgrade( &property ), NULL ); It works, but just seems wrong. Can anyone point me to a source file, preferably in /usr/src somewhere that passes a structure to a function being run as a thread so I may study the proper way to do this? Thank you. -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: threads question
On Monday 14 March 2005 08:57 pm, Daniel Eischen wrote: > On Mon, 14 Mar 2005, Michael C. Shultz wrote: > > Hi, I've just reached a point in a program I'm writing where I'd > > like to do threading. > > > > When I try to start a thread like this: > > > > pthread_create(&thread, &attr, MGPMrUpgrade, property ); > > &property > > You should compile with -Wall and get rid of any warnings. > > > where property is a structure of many variables it doesn't get > > passed to the function. If I do this: > > > > pthread_create(&thread, &attr, MGPMrUpgrade( &property ), NULL ); > > That looks like it will actuall call MGPMrUpgrade() and use its > return value as the function pointer. > > > It works, but just seems wrong. > > > > Can anyone point me to a source file, preferably in /usr/src > > somewhere that passes a structure to a function being run as a > > thread so I may study the proper way to do this? > > src/lib/libpthread/test/sem_d.c > src/lib/libpthread/test/mutex_d.c > src/lib/libpthread/test/sigwait_d.c Great! > > I'd suggest getting Butenhof's "Programming with POSIX Threads" book. I did a google on "Programming with POSIX Threads" and this site popped up first. I remember this guy's stuff from way back when on signals I think, it was great for a beginner so maybe this one is worth looking at too. "http://users.actcom.co.il/~choo/lupg/tutorials/multi-thread/multi-thread.html"; I found the book at Amazon, thanks for the tip! Many thanks! -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: threads question
On Monday 14 March 2005 08:57 pm, Daniel Eischen wrote: > On Mon, 14 Mar 2005, Michael C. Shultz wrote: > > Hi, I've just reached a point in a program I'm writing where I'd > > like to do threading. > > > > When I try to start a thread like this: > > > > pthread_create(&thread, &attr, MGPMrUpgrade, property ); > > &property > > You should compile with -Wall and get rid of any warnings. > > > where property is a structure of many variables it doesn't get > > passed to the function. If I do this: > > > > pthread_create(&thread, &attr, MGPMrUpgrade( &property ), NULL ); > > That looks like it will actuall call MGPMrUpgrade() and use its > return value as the function pointer. > > > It works, but just seems wrong. > > > > Can anyone point me to a source file, preferably in /usr/src > > somewhere that passes a structure to a function being run as a > > thread so I may study the proper way to do this? > > src/lib/libpthread/test/sem_d.c > src/lib/libpthread/test/mutex_d.c > src/lib/libpthread/test/sigwait_d.c > > I'd suggest getting Butenhof's "Programming with POSIX Threads" book. Daniel, sorry to bother you again but I ran into something that is either a bug or I am missing a vital piece of information somewhere. Here is the situation: this works perfectly because I moved MGPMrUpgrade into the same .c file so it would be a static function: structProperty* property; pthread_t threads[NTHREADS]; pthread_create( &threads[0], NULL, zzMGPMrUpgrade, property ); When I use MGPMrUpgrade from a shared library the function runs yet property isn't being passed! I remember from assembly days that there were some stack tricks to be done when making calls to a shared library in order to pass the parameters, I forget what they are (been ages since I did assembly programming) but anyways it seems like with gcc passing the args through the stack to a function in a shared library isn't being handled correctly. Am I missing something obvious? -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: threads question
On Tuesday 15 March 2005 10:19 am, Daniel Eischen wrote: > On Tue, 15 Mar 2005, Michael C. Shultz wrote: > > Daniel, sorry to bother you again but I ran into something that is > > either a bug or I am missing a vital piece of information > > somewhere. Here is the situation: > > > > this works perfectly because I moved MGPMrUpgrade into > > the same .c file so it would be a static function: > > > > structProperty* property; > > pthread_t threads[NTHREADS]; > > pthread_create( &threads[0], NULL, zzMGPMrUpgrade, property ); > > > > When I use MGPMrUpgrade from a shared library the function runs > > yet property isn't being passed! > > > > I remember from assembly days that there were some stack tricks to > > be done when making calls to a shared library in order to pass the > > parameters, I forget what they are (been ages since I did assembly > > programming) but anyways it seems like with gcc passing the args > > through the stack to a function in a shared library isn't being > > handled correctly. Am I missing something obvious? > > I don't know. You have to be sure that whatever property > points to stays valid for the life of the thread (or at > least as long as it is used). I have to reply to you through freebsd-hackers@freebsd.org because your blocking verizon's smtp. I just converted everything to static libraries and now pthread_create is working just fine. The answer is probably something like what you just said, scope being lost when making the call to a shared library. Why is it ok going to a static library but not a shared though? In a few days, when there is time, I will write an assembly routine with nasm to use pthread_create and pass my structProperty argument to a shared library with it, this way I can see just exactly what is being passed through the stack. Then hopefully I can find some C/assembly guru who can look at it and teach me how to do it with C. Messing with and examining stacks in C is way beyond my present abilities. (I'm a C newbie) -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: threads question
On Tuesday 15 March 2005 12:02 pm, you wrote: > On Tue, 15 Mar 2005, Michael C. Shultz wrote: > [cut] > > > The answer is probably something like what you just said, scope > > being lost when making the call to a shared library. Why is it ok > > going to a static library but not a shared though? > > There is probably a race condition, so your code will work *some* of > the time unless you prevent the race condition. I don't have an > answer to your question, but I don't think it is a valid question. > The scope of "*priority" can remain valid or invalid for random > reasons and thus may work some of the time, but the only way to > guarantee that it works all the time is to eliminate the race > condition by making sure that *property is valid though the life of > the thread. > > -Zera Hmmm, should I'll try making "property" global then passing a copy of it to each thread? I think that will guarantee it stays valid. -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: threads question
On Wednesday 16 March 2005 01:40 pm, you wrote: > >this works perfectly because I moved MGPMrUpgrade into > >the same .c file so it would be a static function: > > > >structProperty* property; > >pthread_t threads[NTHREADS]; > >pthread_create( &threads[0], NULL, zzMGPMrUpgrade, property ); > >When I use MGPMrUpgrade from a shared library the function runs > >yet property isn't being passed! > > What do you mean by it not being passed? Does your function receive a > NULL value for the parameter instead of the pointer? (Assuming no > dirty tricks, the function would by definition always be passed > *some* value, though it may be NULL.) I finally figured out what I was doing wrong, it was my lack of understanding threads. here is what I was doing: int main() { int(*fpt)(structProperty*); fpt= ThreadFunct; runFunc( fpt ); } int Funct( int(*fpt)(structProperty*) ) { pthread_t threads[NTHREADS]; structProperty* property pthread_create( &threads[0], NULL, int(*fpt)(structProperty*)ThreadFunct, (void*)property ); } Thats just a rough outline, anyways property was going out of scope while the thread was running, just as Zera and Daniel warned me about. I just moved the declaration into main and switched tool kits to motif from GTK and all is well. Basically I could not pass a function pointer as a call back with paramaters from a GTK button through to actually running the function. That is why I moved the declaration of property down a level in the first place, didn't occur to me how vital scope is when using threads though. Switched to motif and everything passes flawlessly. I wish GTK had either better docs or wasn't broken, not sure what the problem is there, probably my lack of understanding again but I don't care, motif will work for what I need to do. If it wasn't for Zera and Daniel's questions I would have never figured this out! > > > Hmmm, should I'll try making "property" global then passing a copy > > of it to each thread? I think that will guarantee it stays valid. > > Since you are asking about makint it global - what is it *now*? It > would have to be either global, dynamically allocated, or on the > stack. If it's on the stack, things are guaranteed to blow up unless > the function in question is guaranteed to not terminate untill all > threads are done with the data. What is the property pointer being > initialized/set to? > > If it's dynamically allocated you should not have a problem. > > And I don't see how static vs. dynamic linking of libraries should > matter, but perhaps I am overlooking something. I don't get that either, should not have worked either way as far as I can tell. -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: the best form to wait the finish of execution of a child...
On Wednesday 30 March 2005 10:17 am, zean zean wrote: > Hi Hackers: > > Excuse for my badly English. which is the best form to wait the > finish of execution of a child. > > My idea is: > > pid_t chilpid; > > while(childpid != wait(&status)) > ; > > Any aid to obtain the best way is very welcome. > > PD. Excuse my ignorance and I hope they can guide me. > > Bye and thanxs ;) > ___ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to > "[EMAIL PROTECTED]" Here is how I do it, likely someone will have a better way: pid_t pid; pid = fork(); if( !pid ) { execl( "/bin/mkdir", "mkdir", "directory_name", 0 ); } wait( (int*)pid ); -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: portmanager
On Sunday 09 October 2005 07:53, Michael Lednev wrote: > Hello, freebsd-questions. > > anyone tried to run portmanager from crontab? as for me it just > coredumps, what am i doing wrong? its simply 0 0 * * * portmanager -s I'm not sure how to fix it but I've found where portmanager crashes when run from cron, the code is: if( !strncmp( getenv("TERM"), "xterm", 5 ) && isatty(fileno(stdout)) ) { stringSize = strlen( id ) + 1 + strlen( VERSION ) + 1; xtermTitle = malloc( stringSize ); xtermTitle[0] = 0; strcat( xtermTitle, id ); strcat( xtermTitle, " " ); strcat( xtermTitle, VERSION ); printf( "%c]0;%s%c", '\033', xtermTitle, '\007' ); free( xtermTitle ); } This is used to put information in the xterm title screen while portmanager is running, I don't know enough about cron to have a clue how to fix this except to remove it and I don't want to do that. Anyone have any ideas? This particualr code snippet is from portmanager/portmanager.c around line 137 -Mike ps. I've cross posted this to freebsd-hackers because it is a coding problem, so you may want to remove freebsd-questions from any replies. . ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: portmanager
On Wednesday 12 October 2005 13:33, you wrote: > Just a comment from an on-looker to this post. From the getenv > > The getenv() function obtains the current value of the environment vari- > able, name. If the variable name is not in the current environment, a > null pointer is returned. > > So it could potentially be passing in a null pointer to strncmp which is > not good. Is that the problem you're seeing. Easy enough to test the > return from getenv before using it. I tried wrapping it with if ( getenv("TERM") ) { . . . } made no difference. What is really frustrating is I can't get gdb to step through anything in function main ie. whatever is in portmanager.c, every function located in a library is no problem, this also renders the core file useless Guess I'll shift the guts from portmanager.c to a library function then see what gdb says. > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Michael C. Shultz > Sent: 10/12/2005 1:43 PM > To: Michael Lednev; freebsd-questions@freebsd.org; [EMAIL PROTECTED] > Subject: Re: portmanager > > On Sunday 09 October 2005 07:53, Michael Lednev wrote: > > Hello, freebsd-questions. > > > > anyone tried to run portmanager from crontab? as for me it just > > coredumps, what am i doing wrong? its simply 0 0 * * * portmanager -s > > I'm not sure how to fix it but I've found where portmanager crashes when > run from cron, the code is: > > >if( !strncmp( getenv("TERM"), "xterm", 5 ) && isatty(fileno(stdout)) > ) >{ >stringSize = strlen( id ) >+ 1 >+ strlen( VERSION ) >+ 1; >xtermTitle = malloc( stringSize ); >xtermTitle[0] = 0; >strcat( xtermTitle, id ); >strcat( xtermTitle, " " ); >strcat( xtermTitle, VERSION ); >printf( "%c]0;%s%c", '\033', xtermTitle, '\007' ); >free( xtermTitle ); >} > > > This is used to put information in the xterm title screen while portmanager > is running, I don't know enough about cron to have a clue how to fix this > except to remove it and I don't want to do that. Anyone have any ideas? > This particualr code snippet is from portmanager/portmanager.c around line > 137 > > -Mike > > ps. I've cross posted this to freebsd-hackers because it is a coding > problem, so you may want to remove freebsd-questions from any replies. > . > > > > > ___ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "[EMAIL PROTECTED]" ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: portmanager
6(�", fieldNewPortName = 0x28051367 "[EMAIL PROTECTED]<\002t\024\211�213F\004\211E�017B\f�\004<\002u\a\220\2136\205�\232\205t\b\213E\024\213U�211\020\211\203�034 [^_�\215t&", fieldKey = 0x280a6c1c "tsd_lock", fieldValue = 0x9a6322b , fieldChildPortName = 0x28072400 "zP�001", fieldDependencyPortName = 0x0, fieldDependencyPortDir = 0x28049000 , fieldCachePortDir = 0x28072400 "zP�001", fieldAvailablePortName = 0xbfec98 , fieldMakeFileSize = 0x2806be18 "-\002", fieldMakeFileTime = 0x0, fieldInstalledPortName = 0x280a29bc "PB", fieldInstalledPortDir = 0xbfbfed08 "\030\006(\001", fieldUpgradePortDir = 0x28051176 "\211�205�\032\203}�, fieldUpgradePortName = 0x280a6c1c "tsd_lock", strikesDb = 0x9a6322b, cacheDb = 0x2806aa50, commandLineDb = 0xbfbfecdc, configDb = 0x0, dependencyPortsDb = 0xbfbfece0, ignoreDb = 0x0, installedPortsDb = 0x2805106e, outOfDatePortsDb = 0x28072000, portTree = 0x28072200, objIdx = 671421507, portManagerUpdated = 134513476, verbose = 671640963, interactive = 671555840} > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Michael C. Shultz > Sent: 10/12/2005 1:43 PM > To: Michael Lednev; freebsd-questions@freebsd.org; [EMAIL PROTECTED] > Subject: Re: portmanager > > On Sunday 09 October 2005 07:53, Michael Lednev wrote: > > Hello, freebsd-questions. > > > > anyone tried to run portmanager from crontab? as for me it just > > coredumps, what am i doing wrong? its simply 0 0 * * * portmanager -s > > I'm not sure how to fix it but I've found where portmanager crashes when > run from cron, the code is: > > >if( !strncmp( getenv("TERM"), "xterm", 5 ) && isatty(fileno(stdout)) > ) >{ >stringSize = strlen( id ) >+ 1 >+ strlen( VERSION ) >+ 1; >xtermTitle = malloc( stringSize ); >xtermTitle[0] = 0; >strcat( xtermTitle, id ); >strcat( xtermTitle, " " ); >strcat( xtermTitle, VERSION ); >printf( "%c]0;%s%c", '\033', xtermTitle, '\007' ); >free( xtermTitle ); >} > > > This is used to put information in the xterm title screen while portmanager > is running, I don't know enough about cron to have a clue how to fix this > except to remove it and I don't want to do that. Anyone have any ideas? > This particualr code snippet is from portmanager/portmanager.c around line > 137 > > -Mike > > ps. I've cross posted this to freebsd-hackers because it is a coding > problem, so you may want to remove freebsd-questions from any replies. > . > > > > > ___ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to > "[EMAIL PROTECTED]" ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: portmanager
On Thursday 13 October 2005 04:37, you wrote: > Michael C. Shultz wrote: > > if ( getenv("TERM") ) > > { > > . . . > > } > > Anyway you should use code like that for the cases: > char *term; > term = getenv("TERM"); > > And check the variable afterwards. It much better than call getenv() twice. > And the first condition would be: > if( term && !strncmp( term, "xterm", 5 ) && isatty(fileno(stdout)) ) > > And some people not recomend use '!' with str[n]cmp(). Using '== 0' is > better. > > It was someting about a code style. Thanks for the good advice! I'll clean it up for the next change. -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Question about closeing and opening stdin
How do I close then open stdin and keep it set to the same terminal as when it was closed? Everything I've tried so far has met with failure accept this works sort of and I don't get why: signal( SIGALRM, MGPMrTimer ); alarm( 300 ); /* time out in 5 minutes */ answer = getc(stdin); the signal handler just closes descriptor 0 if a timeout occrs: close( 0 ) then to reset stdin I tried this: stdinFileDescriptor = open( "/dev/tty", O_RDWR ) ) stdin = fdopen( stdinFileDescriptor, "r" ); and it works in this instance of the program, but if a second instance is started the second instance can't close stdin. I got the above idea from google, what I don't understand though is there is no /dev/tty! So anyone have any suggested books I might read or tips so I can learn how to do this right, and understand why it works? Thank you, Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Question about closeing and opening stdin
On Tuesday 22 November 2005 10:50, Michael C. Shultz wrote: > How do I close then open stdin and keep it set to the same terminal > as when it was closed? Everything I've tried so far has met with failure > accept this works sort of and I don't get why: > > signal( SIGALRM, MGPMrTimer ); > alarm( 300 ); /* time out in 5 minutes */ > answer= getc(stdin); > > the signal handler just closes descriptor 0 if a timeout occrs: > > close( 0 ) > > > then to reset stdin I tried this: > > stdinFileDescriptor = open( "/dev/tty", O_RDWR ) ) > stdin = fdopen( stdinFileDescriptor, "r" ); > > and it works in this instance of the program, but > if a second instance is started the second instance can't > close stdin. > > I got the above idea from google, what I don't understand though > is there is no /dev/tty! So anyone have any suggested books > I might read or tips so I can learn how to do this right, and understand > why it works? > > Thank you, > > Mike Please disregard the previous post, I figured it out, simple solution. -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Question about closeing and opening stdin
On Wednesday 23 November 2005 11:21, Joan Picanyol i Puig wrote: > [private reply, I'm 100% unsure I understand what you want] > > * Michael C. Shultz <[EMAIL PROTECTED]> [20051122 19:58]: > > How do I close then open stdin and keep it set to the same terminal > > as when it was closed? > > ? If it's closed, you've lost your file descriptor. > > > and it works in this instance of the program, but > > if a second instance is started the second instance can't > > close stdin. > > I seems like you want "file descriptor passing". You can pass > fd's over pipes. > > qvb > -- > pica Here is the solution that finally worked in my case: local_stdin = fopen( "/dev/stdin", "r" ); answer = getc( local_stdin ); if timeout: fclose( local_stdin ); After answer is handled I then just: fclose( local_stdin ); and leave it closed untill needed again I am able to open and close this local_stdin without adversly affecting the global stdin, don't know if it's "the right thing to do" but it works with every test I've thrown at it so far. -Mike ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Cannot upgrade 4.11-RELEASE #0
On Sunday 27 November 2005 14:47, Geoff Mohler wrote: > I am trying to upgrade via buildworld my 4.11-RELEASE #0 system, and I am > running into a few key errors. > > First, I am updated in my cvsup, here is my config file: > > *default host=cvsup3.freebsd.org compress > *default base=/usr > *default prefix=/usr > *default release=cvs > *default delete use-rel-suffix > *default tag=. > src-all rm -rf /usr/src/* rm -rf /usr/obj/* change *default tag=. to *default tag=tag=RELENG_4 You got the sources for 7.0 most likely on your system right now. -Mike > > > When I do a buiuldworld, I get a pile of these: > > /usr/src/usr.bin/make/globals.h:49: stdint.h: No such file or directory > > > My /etc/make.conf includes COMPAT3X and 4X as found in a number of google > searches related to this. > > Just not sure where to go next.. > > Im trying to update this machine remotely, and my KEY issue is that > Imagemagik wont install, oddly with the same stdint.h error(s). > > Ideas? > > --- > "Sixty-six per cent of people currently do not approve of the way that Bush > is handling the war. The other 34 per cent believe that Adam and Eve rode > around naked on Dinosaurs." > -Tina Fey, SNL > ___ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "[EMAIL PROTECTED]" ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: Cannot upgrade 4.11-RELEASE #0
On Sunday 27 November 2005 14:50, Michael C. Shultz wrote: > On Sunday 27 November 2005 14:47, Geoff Mohler wrote: > > I am trying to upgrade via buildworld my 4.11-RELEASE #0 system, and I am > > running into a few key errors. > > > > First, I am updated in my cvsup, here is my config file: > > > > *default host=cvsup3.freebsd.org compress > > *default base=/usr > > *default prefix=/usr > > *default release=cvs > > *default delete use-rel-suffix > > *default tag=. > > src-all > > rm -rf /usr/src/* > rm -rf /usr/obj/* > > change > *default tag=. > to > *default tag=RELENG_4 correction^^ ___ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"