CVS commit: src/usr.bin/tic
Module Name:src Committed By: christos Date: Mon May 20 14:41:37 UTC 2024 Modified Files: src/usr.bin/tic: tic.c Log Message: PR/58270: RVP: tic does not honor the user's umask, output files are 0666. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/tic/tic.c diff -u src/usr.bin/tic/tic.c:1.41 src/usr.bin/tic/tic.c:1.42 --- src/usr.bin/tic/tic.c:1.41 Sat May 11 18:06:57 2024 +++ src/usr.bin/tic/tic.c Mon May 20 10:41:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: tic.c,v 1.41 2024/05/11 22:06:57 christos Exp $ */ +/* $NetBSD: tic.c,v 1.42 2024/05/20 14:41:37 christos Exp $ */ /* * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #endif #include -__RCSID("$NetBSD: tic.c,v 1.41 2024/05/11 22:06:57 christos Exp $"); +__RCSID("$NetBSD: tic.c,v 1.42 2024/05/20 14:41:37 christos Exp $"); #include #include @@ -573,6 +573,7 @@ write_database(const char *dbname) char *tmp_dbname; TERM *term; int fd; + mode_t m; db = cdbw_open(); if (db == NULL) @@ -589,7 +590,9 @@ write_database(const char *dbname) if (cdbw_output(db, fd, "NetBSD terminfo", cdbw_stable_seeder)) err(EXIT_FAILURE, "writing temporary database %s failed", tmp_dbname); - if (fchmod(fd, DEFFILEMODE)) + m = umask(0); + (void)umask(m); + if (fchmod(fd, DEFFILEMODE & ~m)) err(EXIT_FAILURE, "fchmod failed"); if (close(fd)) err(EXIT_FAILURE,
CVS commit: src/usr.bin/tic
Module Name:src Committed By: christos Date: Mon May 20 14:41:37 UTC 2024 Modified Files: src/usr.bin/tic: tic.c Log Message: PR/58270: RVP: tic does not honor the user's umask, output files are 0666. To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: christos Date: Sat May 11 22:06:57 UTC 2024 Modified Files: src/usr.bin/tic: tic.c Log Message: Only mark the terminfo entry promoted if actually was. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/tic/tic.c diff -u src/usr.bin/tic/tic.c:1.40 src/usr.bin/tic/tic.c:1.41 --- src/usr.bin/tic/tic.c:1.40 Sun Mar 29 20:09:06 2020 +++ src/usr.bin/tic/tic.c Sat May 11 18:06:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: tic.c,v 1.40 2020/03/30 00:09:06 roy Exp $ */ +/* $NetBSD: tic.c,v 1.41 2024/05/11 22:06:57 christos Exp $ */ /* * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #endif #include -__RCSID("$NetBSD: tic.c,v 1.40 2020/03/30 00:09:06 roy Exp $"); +__RCSID("$NetBSD: tic.c,v 1.41 2024/05/11 22:06:57 christos Exp $"); #include #include @@ -468,7 +468,7 @@ merge_use(int flags) if (!promoted && rtic->rtype != TERMINFO_RTYPE) { if (promote(rtic, utic) == -1) err(EXIT_FAILURE, "promote"); -promoted = true; +promoted = rtic->rtype == TERMINFO_RTYPE; } merge(rtic, utic, flags);
CVS commit: src/usr.bin/tic
Module Name:src Committed By: christos Date: Sat May 11 22:06:57 UTC 2024 Modified Files: src/usr.bin/tic: tic.c Log Message: Only mark the terminfo entry promoted if actually was. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/usr.bin/tic
On 05/05/2017 14:51, Martin Husemann wrote: > On Fri, May 05, 2017 at 02:20:46PM +0100, Roy Marples wrote: >> Debugging memory use is always important. >> I'll move it to a separate function for clarity, but was hoping a better >> guard name than __VALGRIND__ could be used. >> >> Maybe __DEBUG_MEMORY__ or __FREE_RESOURCES__? > > The point was that we can not rely on the free function to be available in > a host tool build, right? > > So why not something simple like #ifndef HAVE_NBTOOL_CONFIG_H ? > Some tool builds seem to compile with -DNETBSD_TOOLS, that would be another > option. xtos has already done this.
Re: CVS commit: src/usr.bin/tic
On 05/05/2017 14:51, Martin Husemann wrote: > On Fri, May 05, 2017 at 02:20:46PM +0100, Roy Marples wrote: >> Debugging memory use is always important. >> I'll move it to a separate function for clarity, but was hoping a better >> guard name than __VALGRIND__ could be used. >> >> Maybe __DEBUG_MEMORY__ or __FREE_RESOURCES__? > > The point was that we can not rely on the free function to be available in > a host tool build, right? > > So why not something simple like #ifndef HAVE_NBTOOL_CONFIG_H ? > Some tool builds seem to compile with -DNETBSD_TOOLS, that would be another > option. That's for the hdestroy1 case yes which fixes the reported build problem. This discussion has moved onto a more general case of if we should clean up to assist memory debugging by cleaning up at exit and if so what should be name of a general guard be? Or just maybe it's per application and we should not care. Roy
Re: CVS commit: src/usr.bin/tic
On Fri, May 05, 2017 at 02:20:46PM +0100, Roy Marples wrote: > Debugging memory use is always important. > I'll move it to a separate function for clarity, but was hoping a better > guard name than __VALGRIND__ could be used. > > Maybe __DEBUG_MEMORY__ or __FREE_RESOURCES__? The point was that we can not rely on the free function to be available in a host tool build, right? So why not something simple like #ifndef HAVE_NBTOOL_CONFIG_H ? Some tool builds seem to compile with -DNETBSD_TOOLS, that would be another option. Martin
Re: CVS commit: src/usr.bin/tic
On 05/05/2017 12:56, Robert Elz wrote: > Date:Fri, 5 May 2017 11:49:28 +0100 > From:Roy Marples> Message-ID: > > | In this case, exit() isn't called, the main function returns. > > Same thing, return from main is defined as implicitly calling exit. > > | In the RTEMS case, everything runs in one process and a thread is > | launched for each command, sharing memory thus exit() can never be called. > > It doesn't need to "exit" in that sense, but when that thread completes, > whatever resources it allocated needs to be reclaimed (whether they be > file descriptors, or memory, or whatever else). How that is done is the > implementations business, but it needs to be done. > > If not, you'd have bigger problems with tic if you intended to run it > on such a system - I see its grow_tbuf(), save_term(), write_database() > (and main(), though those calls are less of a problem) fuunctions all call > err() on error. err() is defined not to return. No memory gets > freed, nothing gets closed, other that whatever side-effect of the > program completing (calling exit) is. FreeBSD has err_set_exit(void (*exitf)(int)) to handle this. I suppose atexit(3) could be used as well. But that's more of a technical nit than suggesting we make tic 100% free stuff, which is not what I'm suggesting. > | So my question stands, is this something we should support via a compile > | time guard or just not bother? > > Leave the __VALGRIND__ guard in, and clean up in that case only, not that > a program like tic should really be too concerned about memory loss, > because exit (or whatever happens to it when it falls off main) really > needs to clean up for it, but just in case someone wants to debug > its memory use (perhaps it might be of use when debugging the hash table > library functions memory uses - to make sure that when the program does > hdestroy*() that everything is freed ... as while tic really doesn't > care, some other long running daemon program might.) > > Or if debugging memory use in tic isn't important, simply delete the > whole code block (turn the #ifdef __VALGRIND__ into #if 0, and then > delete the entire block later.) Debugging memory use is always important. I'll move it to a separate function for clarity, but was hoping a better guard name than __VALGRIND__ could be used. Maybe __DEBUG_MEMORY__ or __FREE_RESOURCES__? Roy
Re: CVS commit: src/usr.bin/tic
Date:Fri, 5 May 2017 11:49:28 +0100 From:Roy MarplesMessage-ID: | In this case, exit() isn't called, the main function returns. Same thing, return from main is defined as implicitly calling exit. | In the RTEMS case, everything runs in one process and a thread is | launched for each command, sharing memory thus exit() can never be called. It doesn't need to "exit" in that sense, but when that thread completes, whatever resources it allocated needs to be reclaimed (whether they be file descriptors, or memory, or whatever else). How that is done is the implementations business, but it needs to be done. If not, you'd have bigger problems with tic if you intended to run it on such a system - I see its grow_tbuf(), save_term(), write_database() (and main(), though those calls are less of a problem) fuunctions all call err() on error. err() is defined not to return. No memory gets freed, nothing gets closed, other that whatever side-effect of the program completing (calling exit) is. I wouldn't start worrying about programs that don't bother to clean up when they reach the end until you handle all the programs that simply abort when something goes wrong, and clean up nothing at all. | So my question stands, is this something we should support via a compile | time guard or just not bother? Leave the __VALGRIND__ guard in, and clean up in that case only, not that a program like tic should really be too concerned about memory loss, because exit (or whatever happens to it when it falls off main) really needs to clean up for it, but just in case someone wants to debug its memory use (perhaps it might be of use when debugging the hash table library functions memory uses - to make sure that when the program does hdestroy*() that everything is freed ... as while tic really doesn't care, some other long running daemon program might.) Or if debugging memory use in tic isn't important, simply delete the whole code block (turn the #ifdef __VALGRIND__ into #if 0, and then delete the entire block later.) kre
Re: CVS commit: src/usr.bin/tic
On 05/05/2017 10:59, Robert Elz wrote: > Date:Fri, 5 May 2017 09:07:14 +0100 > From:Roy Marples> Message-ID: > > | As we know, parts of NetBSD code are used outside of NetBSD. > > Of course, and if there are any of those for which calling exit() does > not free all resources that have been allocated by the program, they > should be fixed first. In this case, exit() isn't called, the main function returns. In the RTEMS case, everything runs in one process and a thread is launched for each command, sharing memory thus exit() can never be called. > Program bugs are unavoidable (at least we have not yet found any way to > prevent them) - that's bad enough - but allowing bugs in a program to > affect the system long after the program has terminated is intolerable. In this specific case, the program hasn't actually finished. So my question stands, is this something we should support via a compile time guard or just not bother? Roy
Re: CVS commit: src/usr.bin/tic
Date:Fri, 5 May 2017 09:07:14 +0100 From:Roy MarplesMessage-ID: | As we know, parts of NetBSD code are used outside of NetBSD. Of course, and if there are any of those for which calling exit() does not free all resources that have been allocated by the program, they should be fixed first. Program bugs are unavoidable (at least we have not yet found any way to prevent them) - that's bad enough - but allowing bugs in a program to affect the system long after the program has terminated is intolerable. kre
Re: CVS commit: src/usr.bin/tic
On 04/05/2017 23:51, Robert Elz wrote: > Date:Thu, 4 May 2017 14:07:33 + > From:"Roy Marples"> Message-ID: <20170504140733.b327df...@cvs.netbsd.org> > > | Module Name: src > | Committed By: roy > | Date: Thu May 4 14:07:33 UTC 2017 > | > | Modified Files: > | src/usr.bin/tic: tic.c > | > | Log Message: > | Remove __VALGRIND__ guard just clean up. > > > This breaks building on systems that have hcreate() but not hdestroy1() > (like say, NetBSD 6). tic is (apparently) required as a host tool, the > build fails now as ... > > # link tic/tic > cc -O -I/usr/obj/testing/tools/include/compat > -I/release/testing/src/tools/compat -DHAVE_NBTOOL_CONFIG_H=1 > -D_FILE_OFFSET_BITS=64 > -I/release/testing/src/tools/tic/../../usr.bin/tic/../../lib/libterminfo -o > tic tic.lo compile.lo hash.lo -L/usr/obj/testing/tools/lib -lnbcompat -lrt -lz > tic.lo: In function `main': > tic.c:(.text+0xf5b): undefined reference to `hdestroy1' Yes, just received the same error from Andreas about this on a Linux host. > Please revert this change, there doesn't seem to be a point to it > (it is certainly just a waste of time to race around freeing memory > and then immediately call exit() ... unless you are debugging memory > leaks, say with valgrind). Well, that's an interesting perspective. As we know, parts of NetBSD code are used outside of NetBSD. Should we exlcude RT OS's such as RTEMS from using our code in the future by not doing this? Maybe a more common guard could be used? Roy
Re: CVS commit: src/usr.bin/tic
Date:Thu, 4 May 2017 14:07:33 + From:"Roy Marples"Message-ID: <20170504140733.b327df...@cvs.netbsd.org> | Module Name:src | Committed By: roy | Date: Thu May 4 14:07:33 UTC 2017 | | Modified Files: | src/usr.bin/tic: tic.c | | Log Message: | Remove __VALGRIND__ guard just clean up. This breaks building on systems that have hcreate() but not hdestroy1() (like say, NetBSD 6). tic is (apparently) required as a host tool, the build fails now as ... # link tic/tic cc -O -I/usr/obj/testing/tools/include/compat -I/release/testing/src/tools/compat -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -I/release/testing/src/tools/tic/../../usr.bin/tic/../../lib/libterminfo -o tic tic.lo compile.lo hash.lo -L/usr/obj/testing/tools/lib -lnbcompat -lrt -lz tic.lo: In function `main': tic.c:(.text+0xf5b): undefined reference to `hdestroy1' Please revert this change, there doesn't seem to be a point to it (it is certainly just a waste of time to race around freeing memory and then immediately call exit() ... unless you are debugging memory leaks, say with valgrind). kre
CVS commit: src/usr.bin/tic
Module Name:src Committed By: pgoyette Date: Sat Feb 20 06:08:01 UTC 2010 Modified Files: src/usr.bin/tic: tic.c Log Message: Since tic is a host tool, we need to include host system header to get definitions of le16dec() and le16enc(). Solves PR bin/42747 from Henning Petersen To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: pgoyette Date: Sat Feb 20 06:15:06 UTC 2010 Modified Files: src/usr.bin/tic: tic.c Log Message: Wrap the include of sys/endian.h in #ifdef HAVE_SYS_ENDIAN_H to avoid build issues on systems that don't have a sys/endian.h Pointed out by joerg@ To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: pgoyette Date: Sat Feb 20 06:20:46 UTC 2010 Modified Files: src/usr.bin/tic: tic.c Log Message: One more time - do this correctly. Thanks, joerg. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: wiz Date: Thu Feb 11 13:44:14 UTC 2010 Modified Files: src/usr.bin/tic: tic.1 Log Message: Oxford serial comma. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/tic/tic.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: wiz Date: Thu Feb 11 07:00:46 UTC 2010 Modified Files: src/usr.bin/tic: tic.1 Log Message: Sort options (standard order is 0-9AaBbCc...). To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/tic/tic.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: he Date: Fri Feb 5 14:40:07 UTC 2010 Modified Files: src/usr.bin/tic: tic.c Log Message: More adaptation for ports where char is unsigned char. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: roy Date: Fri Feb 5 16:36:09 UTC 2010 Modified Files: src/usr.bin/tic: tic.1 tic.c Log Message: Note that -a no longer sets -x. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/tic/tic.1 cvs rdiff -u -r1.3 -r1.4 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: roy Date: Fri Feb 5 16:54:12 UTC 2010 Modified Files: src/usr.bin/tic: tic.1 Log Message: Fix year. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/tic/tic.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/tic
Module Name:src Committed By: wiz Date: Wed Feb 3 15:51:09 UTC 2010 Modified Files: src/usr.bin/tic: tic.1 Log Message: Use Ex for EXIT STATUS section. Put Ns on same line as previous, to make clearer what happens. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.bin/tic/tic.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.