[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: is $(file ) thread safe when using option -j ?
From: |
Tim Murphy |
Subject: |
Re: is $(file ) thread safe when using option -j ? |
Date: |
Fri, 12 Sep 2014 20:12:13 +0100 |
Oops, fixed recently. My bad. sorry.
On 12 September 2014 20:08, Tim Murphy <address@hidden> wrote:
> Sorry to butt in here but can I just point out that there is a crash in
> $(file) when you don't give it anything to write.
>
> --- a/function.c
> +++ b/function.c
> @@ -2156,14 +2156,25 @@ func_file (char *o, char **argv, const char
> *funcname UN
> }
> else
> {
> - int l = strlen (argv[1]);
> - int nl = (l == 0 || argv[1][l-1] != '\n');
> + char *outstr = argv[1];
> @@ -2156,14 +2156,25 @@ func_file (char *o, char **argv, const char
> *funcname UN
> }
> else
> {
> - int l = strlen (argv[1]);
> - int nl = (l == 0 || argv[1][l-1] != '\n');
> + char *outstr = argv[1];
> + int l, nl;
> + if (outstr == NULL)
> + {
> + outstr="";
> + l = 0;
> + nl = 0;
> + }
> + else
> + {
> + l = strlen (outstr);
> + nl = (l == 0 || outstr[l-1] != '\n');
> + }
>
> - if (fputs (argv[1], fp) == EOF || (nl && fputc ('\n', fp) ==
> EOF))
> + if (fputs (outstr, fp) == EOF || (nl && fputc ('\n', fp) ==
> EOF))
> {
>
>
>
> Cheers,
>
>
> Tim
>
> On 12 September 2014 19:18, Paul Smith <address@hidden> wrote:
>
>> On Fri, 2014-09-12 at 17:43 +0200, Pierre Lindenbaum wrote:
>> > when using $(file )
>> > http://www.gnu.org/software/make/manual/make.html#File-Function .
>> >
>> > If two targets, built in parallel with option -j, both call
>> >
>> > $(file >>log.txt, Building $@)
>> >
>> > is $file thead safe or is it possible to obtain a mixture of both
>> > messages in the file log.txt ?
>>
>> GNU make is actually not multithreaded. It will invoke subprocesses
>> that run in parallel, but make itself does not use threads.
>>
>> This means that, as long as you are talking about a single make
>> invocation, there is no way that multiple instances of file (or any
>> other make function) will intermingle, and so the content above will
>> never mix.
>>
>> If you use recursive make and two make processes are running at the same
>> time via -j and both use $(file ...) to update the same file, then it's
>> possible you'll get intermixing of content (but, as long as the length
>> of the content is small, it's pretty unlikely due to the way the kernel
>> handles write() system calls).
>>
>>
>> _______________________________________________
>> Help-make mailing list
>> address@hidden
>> https://lists.gnu.org/mailman/listinfo/help-make
>>
>
>
>
> --
> You could help some brave and decent people to have access to uncensored
> news by making a donation at:
>
> http://www.thezimbabwean.co.uk/friends/
>
--
You could help some brave and decent people to have access to uncensored
news by making a donation at:
http://www.thezimbabwean.co.uk/friends/