From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x933.google.com (mail-ua1-x933.google.com [IPv6:2607:f8b0:4864:20::933]) by sourceware.org (Postfix) with ESMTPS id 2546C3858D1E for ; Sun, 12 Mar 2023 10:35:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2546C3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ua1-x933.google.com with SMTP id i22so1960874uat.8 for ; Sun, 12 Mar 2023 03:35:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678617341; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=FyVXLv2tCGFAEXFClnoUCcUobOcEG2FIa7bTnO2Bk6A=; b=MLPWUmescaJuCF5X3jA0e1K+9w7dZSjqwGa3Tzzgb+oD0y/jC+dp8Wlw3bI2k+FZZF WatjRPmyVWTB5gDoo0UJlI4rnwNE+uGNw+HMtfMTgmLqZUvRRta45O7qjXdgg68+fdi6 cDRQtHoF3nue0kHhI/rn+ltoIi6Ls5DzzajEUygnyl5izjvi0cnvc0OKWYNTfsJAdHJO vXuFpBQqSknZ+VbIRJwhARbgtgBt+XAADjalQpM9YEWNgjzykMSFwN3xRzIvxVsnrDus yr+FmxGigwMjnEgDnXNdmS/pH5KAF07X+MT5188xr3GyOR3g/7+RAAVNdlzDXuv4/xdz 77rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678617341; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FyVXLv2tCGFAEXFClnoUCcUobOcEG2FIa7bTnO2Bk6A=; b=uWBhZj5ri7JCnX6C0e8nv7sNVKMQn0XnL28DecQG4YbZ0HmRh8DaGkJx/odxwKk1Bw UrYbv5iFOUYJ+iwsYEqLLFqiZBOC1oaJqorxGjsNDePFlsx4t2LZCM/GWyU8xcflCPGR ev78vhoeL9AXWf0HOsGf9rZgF/ecuh2Ij0O19liv6pfUt8Uh3Ty6uPbrroPDU8UQSBJY jZoKYD990S/k+2dXrSkBHfyi2/fqgGiJIHulUrUeTSyqbeNThhvVXa2HlE9kpDMH/n6N UgQWMbO/60dx6iJbu5BGXmv57E9YhRwA3ieDNEDBBcaM4JaVlERfUomRwGb6ZGq8RBcQ Gk7Q== X-Gm-Message-State: AO0yUKUViNLyNQ3CB16u75CzF0gnYnRac3LSdTgkAPF9BL3+IWkXtoun ou/fCQVrubH0xJjD/HEYNGpQHKi96E7pvpbQuWc= X-Google-Smtp-Source: AK7set9/WPqkVdNSrgaW9DFG6N113yvgL0c/hNOQdg+giIHUxEGHiYycnN4HMqspNhOPykbM9gt9FAV14++hjIA6ens= X-Received: by 2002:a1f:4507:0:b0:42d:5ea6:bd58 with SMTP id s7-20020a1f4507000000b0042d5ea6bd58mr9531478vka.3.1678617341425; Sun, 12 Mar 2023 03:35:41 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Csaba Raduly Date: Sun, 12 Mar 2023 11:35:26 +0100 Message-ID: Subject: Re: 3.4.6-1 shm_open always returns -1, errno EINVAL To: Matthew Rickard , cygwin list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Matthew, On Sun, 12 Mar 2023 at 07:44, Matthew Rickard wrote: > > Hi all, > > Cygwin 3.4.6-1 shm_open seems to reject all calls, returning the value > -1 and setting errno to 22 EINVAL. > > For example, this program: > > #include > #include > #include > #include > > int main() { > int res = shm_open("123", O_CREAT | O_RDWR, 0666); > int error = errno; > printf("res=%d errno=%d\n", res, errno); > if (error == EINVAL) > printf("That's EINVAL\n"); > return 0; > } > > Says: > > $ gcc -Og -o tiny tiny.c; ./tiny > res=-1 errno=22 > That's EINVAL > https://man7.org/linux/man-pages/man3/shm_open.3.html says: For portable use, a shared memory object should be identified by a name of the form /somename; that is, a null-terminated string of up to NAME_MAX (i.e., 255) characters consisting of an initial slash, followed by one or more characters, none of which are slashes. Changing the shm_open call to shm_open("/123", O_CREAT | O_RDWR, 0666); returns 3 and sets errno to zero. Csaba -- You can get very substantial performance improvements by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler So if you're looking for a completely portable, 100% standards-conformant way to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)